首页 > 解决方案 > CompileJava 找不到元模型,失败

问题描述

我已经有一个项目至少一年了,并且可以很好地编译。现在,当我尝试编译元模型时,缺少元模型并且 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; en_US (注)

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: "*"
}

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

标签: gradlenetbeansmetamodelnetbeans-8.2

解决方案


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

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

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


推荐阅读