我正在使用Srping启动,MongoDB,kotlin。我有一份文件:
@Document(collection = "car")
class Car @JvmOverloads constructor(
@Id
var id: String? = null,
@Field("colorId")
var colorId: String? = null,
@Field("parts")
var parts: Set<Part>? = null
) {
enum class Part {
SCREW, CLUTCH, TIRE
}
}
这是使用“生成”错误的方法的存储库:
interface CarRepository : MongoRepository<Car, String>{
fun findAllByColorId(colorId: String): List<Car>
}
当我运行它时,我收到以下错误:
ERROR 7752 [dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate com.foo.bar.Car$Part using constructor fun <init>(): com.foo.bar.Car.Part with arguments null,null] with root cause
java.lang.IllegalArgumentException: Number of provided arguments should be less of equals than number of constructor parameters
我对kotlin(实际上是mongo)全新。