我有一个项目至少一年,并且可以编译。现在,当我尝试编译元模型时,缺少并且compilejava任务失败。我不确定问题是否是因为存在版本问题或什么问题。请记住,在使用当前gradle构建脚本和项目文件结构运行构建之前,我没有任何问题。

该代码在带有netBeans的Java中:
产品版本:NetBeans IDE 8.2(内部版本201609300101)
更新:NetBeans IDE更新为版本NetBeans 8.2 Patch 2
Java:1.8.0_171; Java HotSpot(TM)64位服务器VM 25.171-b11
运行时:Java(TM)SE运行时环境1.8.0_171-b11
系统:在amd64上运行的Windows 10版本10.0; cp1252; zh_(nb)

Gradle 支持1.4.4

我试图“设置生成的路径”,但是没有用。
我还尝试创建自己的元模型类副本,然后在动态查询构建器中引用它。它会编译,但是当我测试查询时,我不断收到空指针异常。

如果我按住Ctrl键使用元模型单击类文件中的元模型,它将加载元模型类文件,我认为生成器在编译时创建元模型对象时存在一些问题。

apply plugin: 'java'
apply plugin: 'war'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

war.archiveName "ApplicationWarehouseService.war"
war {
    webInf {from 'src/main/resources/application.xml' }
}

if (!hasProperty('mainClass')) {
    ext.mainClass = 'test'
}

repositories {
    mavenCentral()
    maven {
        url "http://jaspersoft.artifactoryonline.com/jaspersoft/third-party-ce-artifacts/"
    }
}

dependencies {
compile 'javax.servlet:javax.servlet-api:4.0.0'
compile 'commons-validator:commons-validator:1.6'

compile 'org.springframework:spring-webmvc:5.0.5.RELEASE'
compile 'org.springframework.security:spring-security-web:5.0.4.RELEASE'
compile 'org.springframework.security:spring-security-config:5.0.4.RELEASE'
compile 'org.springframework:spring-jdbc:5.1.6.RELEASE'
compile 'org.springframework:spring-aop:5.1.6.RELEASE'
compile 'org.springframework:spring-context:5.1.6.RELEASE'
compile 'org.springframework:spring-context-support:5.1.6.RELEASE'

compile 'org.springframework.data:spring-data-jpa:2.1.6.RELEASE'
compile 'org.springframework:spring-orm:5.1.6.RELEASE'
compile 'com.microsoft.sqlserver:mssql-jdbc:6.4.0.jre8'
compile 'org.hibernate:hibernate:3.5.4-Final'
compile 'org.hibernate:hibernate-core:5.4.2.Final'
compile 'org.hibernate:hibernate-jpamodelgen:5.4.3.Final'

compile 'org.aspectj:aspectjrt:1.9.0'
compile 'org.aspectj:aspectjweaver:1.9.0'
compile 'org.apache.tomcat:tomcat-jdbc:9.0.7'
compile 'com.fasterxml.jackson.core:jackson-databind:2.9.5'
compile 'commons-fileupload:commons-fileupload:1.3.3'
compile 'javax.mail:javax.mail-api:1.6.1'

compile 'javax:javaee-api:8.0'
compile 'javax.servlet:jstl:1.2'
compile 'org.hibernate.validator:hibernate-validator:6.0.9.Final'
compile 'org.apache.logging.log4j:log4j-core:2.11.0'
compile files('C:/Program Files (x86)/Microsoft JDBC Driver 4.1 for SQL Server/sqljdbc_4.1/enu/jre7/sqljdbc41.jar')
//compile 'com.lowagie:itext:4.2.2'
compile 'com.lowagie:itext:2.1.7'
compile 'net.sf.jasperreports:jasperreports:6.1.0'
//    compile 'com.itextpdf:itextpdf:5.5.13'
//    compile 'net.sf.jasperreports:jasperreports:6.5.1'
compile 'javax.money:money-api-bp:1.0'

compile 'org.json:json:20180130'

compile 'javax.xml.bind:jaxb-api:2.3.0'



compile group: 'ar.com.fdvs', name: 'DynamicJasper', version: '5.1.1'
compile group: 'ar.com.fdvs', name: 'DynamicJasper-core-fonts', version: '1.0'

testCompile group: 'junit', name: 'junit', version: '4.10'
testCompile 'org.springframework:spring-test:5.0.5.RELEASE'
}

configurations.all*.dependencies*.withType(ModuleDependency)*.each {
    it.exclude group: "org.bouncycastle", module: "*"
    it.exclude group: "bouncycastle", module: "*"
}

理想情况下,我想让我的项目创建元模型并成功编译。

最佳答案

我找到了我添加的解决方案

annotationProcessor('org.hibernate:hibernate-jpamodelgen:5.4.3.Final')

在依赖项部分。编译就好了。

08-05 19:27