Spring Boot Data JDBC + Querydsl错误“原因:找不到类型的属性计数”

问题描述

我试图在Kotlin中将Spring数据JDBC与Query DSL一起使用。 这是我的资料库

@Repository
interface UserRepository : PagingAndSortingRepository<User,Int>,QuerydslPredicateExecutor<User> {}

我的实体是一个简单的数据对象

@Entity
@Table(name = "user")
data class User(
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "user_id_seq")
    @SequenceGenerator(name = "user_id_seq",sequenceName = "user_id_seq",allocationSize = 1)
    val id: Int? = null,val name: String,val surname: String)

我已将这些行添加到我的build.gradle

implementation("com.querydsl:querydsl-sql-spring:4.4.0") {
        exclude group: 'joda-time',module: 'joda-time'
    }
kapt "com.querydsl:querydsl-apt:4.4.0:jpa"

我已经在我的Spring应用程序中添加@EnableJdbcrepositories注释

但是当我尝试启动我的应用程序时,出现此错误

Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository' defined in my.tests.querydsl.repositories.UserRepository defined in @EnableJdbcRepositories declared on 
JdbcRepositoriesRegistrar.EnableJdbcRepositoriesConfiguration: Invocation of init method Failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract long org.springframework.data.querydsl.QuerydslPredicateExecutor.count(com.querydsl.core.types.Predicate)! Reason: No property count found for type User!

我也尝试删除@EnableJdbcrepositories注释,但错误仍然存​​在。 我做错了什么?我缺少一些依赖吗?

谢谢

解决方法

Infobip Spring Data Querydsl 为 Spring Data JDBC(除其他外)提供 QuerydslPredicateExecutor 片段支持。

有了它,UserRepository 定义应该像定义的那样工作,查看模块 README.md JDBC section 了解详细信息。 如果您需要 SQLQuerySQLUpdateClause 或删除 Predicate 支持,请不要错过 QuerydslJdbcFragment

,

Spring-Data书中说,只有Spring Data JPA和MongoDB支持QuerydslPredicateExecutor

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...