2017-04-19 44 views
-1

我試圖通過Gradle構建一個Web應用程序並打包一個war文件。使用「gradle-3.5」構建Web應用程序,但始終在JPA中失敗

的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」 失敗 以下是錯誤mesage的一部分:

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來說,結果是成功的。

+0

單獨的依賴性。 – Opal

+0

目前沒有足夠的信息。你在用什麼庫?谷歌搜索錯誤消息,例如我發現這個錯誤報告:https://github.com/rzwitserloot/lombok/issues/778 –

回答

0

如果添加JPA 1.0.2的依賴項,編譯將失敗,因爲一些註釋依賴於JPA 2.1。

由於'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'已經包含了JPA 2.1 API,你不需要相反附加圖片請加build.gradle`的'源代碼和錯誤消息對javax.persistence:persistence-api

+0

非常感謝。刪除「persistence-api.jar」後,它運行良好。 –

相關問題