Gradle试图构建一个Web应用程序并打包war文件。
build.gradle
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
sourceCompatibility = 1.8
version = '1.0'
compileJava.options.encoding='UTF-8'
webAppDirName = 'fbs-report' //set webapp root
sourceSets {
main {
java {
srcDir 'src'
exclude '**/SlablistDload1Controller.java'
exclude '**/SlablistDload2Controller.java'
exclude '**/DormantDownloadController.java'
exclude '**/NewnewController.java'
}
resources {
srcDir 'config' //prorperties
}
}
}
repositories {
maven { url "http://maven.springframework.org/milestone" }
maven { url "http://repo.maven.apache.org/maven2" }
maven { url "http://repo1.maven.org/maven2/" }
maven { url "http://amateras.sourceforge.jp/mvn/" }
maven { url "http://repo.springsource.org/libs-release"}
mavenCentral()
}
configurations {
compile.exclude group: 'org.freemarker', module: 'freemarker'
compile.exclude group: 'javax.servlet', module: 'servlet-api'
compile.exclude group: 'jboss', module: 'javassist'
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
compile fileTree(include: ['*.jar'], dir: 'libs')
//spring framework
compile group: 'org.springframework', name: 'spring-context', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-test', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-core', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-beans', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-jdbc', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-aop', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-aspects', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-oxm', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-messaging', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-websocket', version: '4.3.7.RELEASE'
compile group: 'org.springframework', name: 'spring-instrument', version: '4.3.7.RELEASE'
//spring data
compile group: 'org.springframework.data', name: 'spring-data-commons', version: '1.12.6.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.11.1.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-rest-webmvc', version: '2.5.6.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-rest-core', version: '2.5.6.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-jdbc-core', version: '1.2.1.RELEASE'
compile group: 'org.springframework.data', name: 'spring-cql', version: '1.4.6.RELEASE'
compile group: 'org.springframework.data', name: 'spring-data-rest-parent', version: '2.5.6.RELEASE'
//spring-ws
compile group: 'org.springframework.ws', name: 'spring-xml', version: '2.4.0.RELEASE'
compile group: 'org.springframework.ws', name: 'spring-ws-security', version: '2.4.0.RELEASE'
compile group: 'org.springframework.ws', name: 'spring-ws-test', version: '2.4.0.RELEASE'
compile group: 'org.springframework.ws', name: 'spring-ws-support', version: '2.4.0.RELEASE'
//spring-boot
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '1.4.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '1.5.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-autoconfigure', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-configuration-processor', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '1.4.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot', version: '1.5.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '1.4.2.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.5.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-websocket', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-devtools', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-log4j', version: '1.3.8.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-test', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-deployment-tests', version: '1.4.2.RELEASE'
//compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '1.4.2.RELEASE'
//hibernate
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-validator', version: '5.3.3.Final'
compile group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-ehcache', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-c3p0', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-jpamodelgen', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.5.5.Final'
compile group: 'org.hibernate', name: 'hibernate-tools', version: '5.1.0.Final'
compile group: 'org.hibernate', name: 'hibernate-testing', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-infinispan', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-validator-cdi', version: '5.3.3.Final'
compile group: 'org.hibernate', name: 'hibernate-validator-annotation-processor', version: '5.3.3.Final'
compile group: 'org.hibernate.hql', name: 'hibernate-hql-parser', version: '1.3.0.Final'
compile group: 'org.hibernate.hql', name: 'hibernate-hql-testing', version: '1.3.0.Final'
compile group: 'org.hibernate', name: 'hibernate-java8', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-osgi', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-validator-test-utils', version: '5.3.3.Final'
compile group: 'org.hibernate', name: 'hibernate-validator-osgi', version: '5.3.3.Final'
compile group: 'org.hibernate', name: 'hibernate-gradle-plugin', version: '5.2.5.Final'
compile group: 'org.hibernate', name: 'hibernate-validator-parent', version: '5.3.3.Final'
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final'
//compile group: 'javax.persistence', name: 'persistence-api', version: '1.0.2'
compile group: 'org.projectlombok', name: 'lombok', version: '1.16.16'
//apache common
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
compile group: 'org.apache.activemq', name: 'activemq-core', version: '5.7.0'
compile group: 'org.apache.activemq.protobuf', name: 'activemq-protobuf', version: '1.1'
compile group: 'annogen', name: 'annogen', version: '0.1.0'
compile group: 'antlr', name: 'antlr', version: '2.7.7'
compile group: 'aopalliance', name: 'aopalliance', version: '1.0'
compile group: 'org.aspectj', name: 'aspectjrt', version: '1.8.10'
compile group: 'org.aspectj', name: 'aspectjweaver', version: '1.8.10'
compile group: 'org.apache.ws.commons.axiom', name: 'axiom-api', version: '1.2.20'
compile group: 'org.apache.axis2', name: 'axis2', version: '1.4.1'
compile group: 'org.apache.axis2', name: 'axis2-saaj', version: '1.4.1'
compile group: 'org.apache.commons', name: 'commons-pool2', version: '2.4.2'
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
//compile group: 'org.quartz-scheduler', name: 'quartz', version: '2.2.3'
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.1.1'
compile group: 'net.sf.json-lib', name: 'json-lib', version: '2.4', classifier: 'jdk15'
//compile group: 'oro', name: 'oro', version: '2.0.8'
//compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23'
//compile group: 'jboss', name: 'javassist', version: '3.22.0-CR1'
compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.2'
compile group: 'commons-io', name: 'commons-io', version: '2.5'
compile group: 'org.jfree', name: 'jcommon', version: '1.0.23'
compile group: 'org.jfree', name: 'jfreechart', version: '1.0.19'
compile group: 'net.minidev', name: 'json-smart', version: '1.0.9'
compile group: 'xerces', name: 'xercesImpl', version: '2.11.0'
}
当我执行
$ gradle build
时,总是在任务“compilejava”中失败这是错误消息的一部分:
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:62: error: cannot find symbol
classes={
^
symbol: method classes()
location: @interface SqlResultSetMapping
D:\fbs-UAT\fbs-report\src\model\ConvertModel.java:114: error: cannot find symbol
@OneToMany(cascade= { CascadeType.ALL }, fetch=FetchType.EAGER, orphanRemoval=true)
^
symbol: method orphanRemoval()
location: @interface OneToMany
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:66: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysId", type=Long.class),
^
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:66: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysId", type=Long.class),
^
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:67: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysCreateUser", type=String.class),
^
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:67: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysCreateUser", type=String.class),
^
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:68: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysCreateTime", type=Date.class),
^
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:68: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysCreateTime", type=Date.class),
^
D:\fbs-UAT\fbs-report\src\MonitorModel.java:69: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysModifyUser", type=String.class),
^
D:\fbs-UAT\fbs-report\src\model\MonitorModel.java:69: error: duplicate element '<any?>' in annotation @<any?>.
@ColumnResult(name="sysModifyUser", type=String.class),
^
顺便说一句,如果拿走了JPA的代码,那么结果就是成功。
最佳答案
如果在JPA 1.0.2上添加依赖项,则编译将失败,因为某些注释依赖于JPA 2.1。
由于'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'
已经包含JPA 2.1 API,因此不需要单独依赖javax.persistence:persistence-api
关于java - 使用 “gradle-3.5”构建Web应用程序,但在JPA中始终失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43488608/