我正在尝试从 spring boot gradle 项目创建对 mongo 数据库的动态查询。
我的gradle版本:5.6.1
这是我的 build.gradle 文件:
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.onssoftware'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
// https://mvnrepository.com/artifact/com.querydsl/querydsl-mongodb
compile group: 'com.querydsl', name: 'querydsl-mongodb', version: '4.2.2'
// https://mvnrepository.com/artifact/com.querydsl/querydsl-apt
compile group: 'com.querydsl', name: 'querydsl-apt', version: '4.2.2'
//annotationProcessor group: 'com.querydsl', name: 'querydsl-apt', version: '4.2.2'
annotationProcessor "com.querydsl:querydsl-apt:4.2.2"
//annotationProcessor("org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor")
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
}
test {
useJUnitPlatform()
}
我的 application.properties 文件:
spring.data.mongodb.username = user
spring.data.mongodb.password = pass
spring.data.mongodb.host = 172.17.0.2
spring.data.mongodb.port = 27017
spring.data.mongodb.database = test_db
问题是:没有为我的文档生成 Q 类。
欢迎任何建议。谢谢。
最佳答案
可能与 Java QueryDsl code generation does not generate Q class 重复
也许是因为 Gradle 版本:尝试检查此 https://github.com/ewerk/gradle-plugins/issues/112
或者你忘记包括
compile group: 'org.mongodb.morphia', name: 'morphia', version: '1.3.2'
同时,我将尝试使用 @viktorgt 重现存储库
关于java - 如何将 querydsl-mongodb 添加到 Spring Boot Gradle 5.6.1 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59580587/