我想用QueryDslPredicateExecutor接口創建UserTask實體的可篩選列表,因此查詢字符串中給出的參數將自動處理爲Predicate。SpringBoot Couchbase集成
我有以下類/接口
public interface UserTaskQuerydslRepository extends CrudRepository<UserTask, String>,
QueryDslPredicateExecutor<UserTask>, QuerydslBinderCustomizer<QUserTask> {
@Override
default void customize(QuerydslBindings bindings, QUserTask userTask) {
...
}
}
UserTask是我的類,它表示(couchbase)模型
@QueryEntity
@Document(expiry = 0)
public class UserTask {
@Id
private String id;
...
}
如果我註釋此類@QueryEntity然後Maven的生成QUserTask類對我來說
@Generated("com.mysema.query.codegen.EntitySerializer")
public class QUserTask extends EntityPathBase<UserTask> {
private static final long serialVersionUID = 493434469L;
public static final QUserTask userTask = new QUserTask("userTask");
public final StringPath id = createString("id");
...
public QUserTask(String variable) {
super(UserTask.class, forVariable(variable));
}
public QUserTask(Path<? extends UserTask> path) {
super(path.getType(), path.getMetadata());
}
public QUserTask(PathMetadata<?> metadata) {
super(UserTask.class, metadata);
}
}
要生成QUERTask我添加了follo翼線的pom.xml
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/apt</outputDirectory>
<processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
<processor>com.mysema.query.apt.QuerydslAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>3.4.3</version>
</dependency>
</dependencies>
</plugin>
在我們既有JPA實體和couchbase實體的項目,這就是爲什麼我有JPAAnnotationProcessor那裏。
如果我運行應用程序這樣我得到以下錯誤:
org.springframework.data.mapping.PropertyReferenceException: No property findAll found for type UserTask!
我想我的註釋與UserTaskQuerydslRepository @NoRepositoryBean,它解決了我的findAll問題,但是當我嘗試這個倉庫@Inject到資源(或控制器,JHipster稱之爲資源)我得到以下錯誤
No qualifying bean of type [.UserTaskQuerydslRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.inject.Inject()}
誰能幫我我做了什麼錯?
春數據Couchbase沒有QueryDsl支持,因此庫不能被實現爲bean,所以Spring不能注入存儲庫bean。 – mp911de
理論上它有http://docs.spring.io/spring-data/couchbase/docs/current/reference/html/#core.extensions.querydsl – aBnormaLz
你的Spring配置是什麼樣的? 也許你有多個Spring上下文?您也可以通過查看日誌來驗證存儲庫bean是否已創建。 – Jeremy