我使用gradle构建我的Web应用程序。我想使用QueryDSL,所以我使用this插件来生成QueryDSL类型。这是我的build.gradle文件。
plugins {
id 'war'
id 'com.ewerk.gradle.plugins.querydsl' version '1.0.9'
id 'idea'
}
repositories {
jcenter()
}
querydsl {
jpa = true
library = 'com.querydsl:querydsl-apt:4.2.1'
}
apply plugin: 'idea'
sourceSets {
querydsl {
java {
srcDirs = [
'src/querydsl/java'
]
}
compileClasspath += sourceSets.main.output + sourceSets.test.output
runtimeClasspath += sourceSets.main.output + sourceSets.test.output
}
}
idea{
module {
sourceDirs += file('src/querydsl/java')
}
}
dependencies {
// Spring
compile 'org.springframework:spring-core:5.0.5.RELEASE'
compile 'org.springframework:spring-context:5.0.5.RELEASE'
compile 'org.springframework:spring-context-support:5.0.5.RELEASE'
compile 'org.springframework:spring-aspects:5.0.5.RELEASE'
compile 'org.springframework:spring-aop:5.0.5.RELEASE'
compile 'org.springframework:spring-webmvc:5.0.5.RELEASE'
compile 'org.springframework.data:spring-data-commons:2.0.6.RELEASE'
compile 'org.springframework.data:spring-data-jpa:2.0.6.RELEASE'
compile 'org.springframework.security:spring-security-web:5.0.5.RELEASE'
compile 'org.springframework.security:spring-security-config:5.0.5.RELEASE'
// Hibernate
compile 'org.hibernate:hibernate-entitymanager:5.2.17.Final'
compile 'org.hibernate.common:hibernate-commons-annotations:5.0.3.Final'
compile 'org.hibernate.validator:hibernate-validator:6.0.9.Final'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final'
// QueryDSL
compile 'com.querydsl:querydsl-apt:4.2.1'
compile 'com.querydsl:querydsl-core:4.2.1'
compile 'com.querydsl:querydsl-jpa:4.2.1'
compile 'com.querydsl:querydsl-sql:4.2.1'
compile 'com.querydsl:querydsl-sql-spring:4.2.1'
// PostgreSQL
compile 'org.postgresql:postgresql:42.2.2'
// Joda Time
compile group: 'joda-time', name: 'joda-time', version: '2.10'
// Apache Commons
compile 'org.apache.commons:commons-lang3:3.7'
compile 'org.apache.commons:commons-text:1.4'
compile 'commons-io:commons-io:2.6'
// Google Guava
compile 'com.google.guava:guava:25.0-jre'
// Jackson
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.5'
// Java
compile 'javax.el:javax.el-api:3.0.0'
compile 'javax.xml:jaxb-api:2.1'
compile 'javax.xml:jaxb-impl:2.1'
compile 'javax.cache:cache-api:1.1.0'
compile 'org.glassfish:javax.el:3.0.0'
compile 'javax.annotation:jsr250-api:1.0'
providedCompile 'javax.servlet:javax.servlet-api:4.0.1'
providedCompile 'javax.annotation:javax.annotation-api:1.3.2'
// Ehcache
compile 'org.ehcache:ehcache:3.5.2'
// Logging
compile 'ch.qos.logback:logback-core:1.2.3'
compile 'ch.qos.logback:logback-classic:1.2.3'
// Test
testCompile 'org.springframework:spring-test:5.0.5.RELEASE'
testCompile 'org.springframework.security:spring-security-test:5.0.5.RELEASE'
testCompile 'org.testng:testng:6.14.3'
testCompile 'org.mockito:mockito-all:1.10.19'
testCompile 'org.hamcrest:hamcrest-all:1.3'
}
test {
useTestNG()
}
//================================================================================
// PROFILES
//================================================================================
if (project.hasProperty("production")) {
sourceSets.main.resources.srcDirs = [
'src/main/resources/commons',
'src/main/resources/production',
]
sourceSets.test.resources.srcDirs = [
'src/test/resources/commons',
'src/test/resources/production',
]
} else {
sourceSets.main.resources.srcDirs = [
'src/main/resources/commons',
'src/main/resources/development',
]
sourceSets.test.resources.srcDirs = [
'src/test/resources/commons',
'src/test/resources/development',
]
}
当我从控制台构建应用程序时,一切正常,但是Idea在生成的源代码中报告了许多错误。例如:
我使用Java9。有什么主意吗?
答案 0 :(得分:0)
您有需要注释处理的库。默认情况下,所有IntelliJ项目都禁用此功能。
您将要确保启用用于项目的适当插件。即龙目岛或您生成代码的注释
启用注释处理器
Settings > Build, Execution, Deployment > Compiler > Annotation Processor
启用注释处理器
请参阅此问题以获取更多参考,并默认启用它:Enable Annotation processors by default