小编Chr*_*sey的帖子

扩展 Spring Data CoroutineCrudRepository 抛出 PropertyReferenceException

在我的项目中,我有一个 Kotlin ( 1.3.72) Spring Boot( 2.3.3.RELEASE) JPA 支持的存储库,它工作得很好,Spring 应用程序上下文正常启动,项目通过了所有测试,等等:

@Repository
interface MappingRepository : CrudRepository<RoutingMapping, Long> {
    fun findByCompanyId(companyId: Long): RoutingMapping?
}
Run Code Online (Sandbox Code Playgroud)

当我将其切换为像这样扩展org.springframework.data.repository.kotlin.CoroutineCrudRepository而不改变任何其他内容时:

@Repository
interface MappingRepository : CoroutineCrudRepository<RoutingMapping, Long> {
    fun findByCompanyId(companyId: Long): RoutingMapping?
}
Run Code Online (Sandbox Code Playgroud)

Spring 应用程序上下文启动失败并抛出以下错误:

Caused by: org.springframework.data.mapping.PropertyReferenceException:
No property count found for type RoutingMapping!`
Run Code Online (Sandbox Code Playgroud)

这是一个令人困惑的异常,因为RoutingMapping它是映射的@Entity。我不清楚我是否遗漏了一些东西@Entity,或者是否是我对如何使用的误解org.springframework.data.repository.kotlin.CoroutineCrudRepository


Caused by: org.springframework.data.mapping.PropertyReferenceException: No property count found for type RoutingMapping!
    at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382)
    at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358)
    at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311)
    at java.base/java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:330) …
Run Code Online (Sandbox Code Playgroud)

spring-data spring-data-jpa kotlin kotlin-coroutines

6
推荐指数
1
解决办法
1713
查看次数