尚未初始化spring::lateinit属性userRepo DataTable.kt 类数据表(私有值参数:多值映射,私有值搜索字段:数组){ @自动连线 private val userService:userService=userService() private fun getAllCnt():Int{ 返回userService.countAll() } UserRepo.kt @存储库 接口UserRepo:JpaRepository{ @查询(value=“SELECT COUNT(*)FROM users”,nativeQuery=true) fun countAll():Int } UserService.kt @服务 类用户服务{ @自动连线 私有lateinit var userRepo:userRepo fun countAll():Int{ 返回userRepo.countAll() } } 错误

尚未初始化spring::lateinit属性userRepo DataTable.kt 类数据表(私有值参数:多值映射,私有值搜索字段:数组){ @自动连线 private val userService:userService=userService() private fun getAllCnt():Int{ 返回userService.countAll() } UserRepo.kt @存储库 接口UserRepo:JpaRepository{ @查询(value=“SELECT COUNT(*)FROM users”,nativeQuery=true) fun countAll():Int } UserService.kt @服务 类用户服务{ @自动连线 私有lateinit var userRepo:userRepo fun countAll():Int{ 返回userRepo.countAll() } } 错误,spring,kotlin,Spring,Kotlin,lateinit属性userRepo尚未初始化 也许我认为不能定义userRepo。 但是我不知道如何定义userRepo。检查这个答案:@SimrandeepSingh谢谢你的评论,但我不知道为什么推荐这个问题。答案是为java.lang.NoClassDefFoundError添加kotlin reflect依赖项:kotlin/reflect/full/KClass。因此认为这可能是相关的。检查这个答案:@SimrandeepSingh tha谢谢你的评论,但我不知道为什么推荐这个问题。答

lateinit属性userRepo尚未初始化

也许我认为不能定义userRepo。
但是我不知道如何定义userRepo。

检查这个答案:@SimrandeepSingh谢谢你的评论,但我不知道为什么推荐这个问题。答案是为java.lang.NoClassDefFoundError添加kotlin reflect依赖项:kotlin/reflect/full/KClass。因此认为这可能是相关的。检查这个答案:@SimrandeepSingh tha谢谢你的评论,但我不知道为什么推荐这个问题。答案是为java.lang.NoClassDefFoundError添加kotlin reflect依赖项:kotlin/reflect/full/KClasses。因此我认为这可能是相关的。