Annotation processor ‘org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor’ not found

huangapple 未分类评论57阅读模式
英文:

Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found

问题

我正在尝试在我的Spring Boot应用程序中实现Hibernate元模型。在构建应用程序时,我遇到了以下错误:

    注解处理器 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' 未找到

下面是我的Gradle配置和详细错误信息:

buildscript {
	ext {
		springBootVersion = '2.2.6.RELEASE'
	}
	repositories {
		mavenCentral()
		maven {
			url "https://plugins.gradle.org/m2/"
		}
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
		classpath('se.transmode.gradle:gradle-docker:1.2')
		classpath("gradle.plugin.at.comm_unity.gradle.plugins:jpamodelgen-plugin:1.1.4")
	}
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: "jacoco"
apply from: 'docker.gradle'
apply plugin: "at.comm_unity.gradle.plugins.jpamodelgen"

sourceCompatibility = 1.8

bootJar {
	launchScript()
}

repositories {
	mavenCentral()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-security'
	implementation 'org.springframework.boot:spring-boot-starter-actuator'
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
	implementation 'org.springframework.boot:spring-boot-starter-mail'
	implementation 'org.springframework.boot:spring-boot-starter-quartz'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	implementation 'io.jsonwebtoken:jjwt-api:0.10.5'
	implementation 'org.flywaydb:flyway-core'
	compileOnly 'org.projectlombok:lombok'
	implementation 'org.springframework.boot:spring-boot-devtools'
	runtimeOnly 'com.h2database:h2'
	runtimeOnly 'mysql:mysql-connector-java'
	runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.10.5'
	runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.10.5'
	annotationProcessor 'org.projectlombok:lombok'
	annotationProcessor('org.hibernate:hibernate-jpamodelgen:5.4.14.Final')
	testImplementation('org.springframework.boot:spring-boot-starter-test') {
		exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
	}
	testImplementation 'org.springframework.security:spring-security-test'
}

test.reports.junitXml.setDestination(file("${buildDir}/test-results"))

jacocoTestReport {
	reports {
		html.destination file("${buildDir}/jacocoHtml")
	}
}

jpaModelgen {
	library = "org.hibernate:hibernate-jpamodelgen"
	jpaModelgenSourcesDir="src/jpaModelgen/java"
}

sourceSets {
	main {
		java {
			srcDirs += "src/jpaModelgen/java"
		}
	}
}

在运行命令 ./gradlew build --info 来启动应用程序时,我遇到以下错误:

![enter image description here][1]

我正在使用Spring Boot 2.2.6,是否有适用于hibernate-jpamodelgen的版本兼容性可用。


<details>
<summary>英文:</summary>

I am trying to implement hibernate metamodel in my spring boot application. I am getting 

    Annotation processor &#39;org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor&#39; not found

above error, while building applications.

My Gradle configuration and detailed error given below

buildscript {
ext {
springBootVersion = '2.2.6.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
classpath("gradle.plugin.at.comm_unity.gradle.plugins:jpamodelgen-plugin:1.1.4")
}
}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: "jacoco"
apply from: 'docker.gradle'
apply plugin: "at.comm_unity.gradle.plugins.jpamodelgen"

sourceCompatibility = 1.8

bootJar {
launchScript()
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-quartz'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'io.jsonwebtoken:jjwt-api:0.10.5'
implementation 'org.flywaydb:flyway-core'
compileOnly 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'mysql:mysql-connector-java'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.10.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.10.5'
annotationProcessor 'org.projectlombok:lombok'
annotationProcessor('org.hibernate:hibernate-jpamodelgen:5.4.14.Final')
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.springframework.security:spring-security-test'
}

test.reports.junitXml.setDestination(file("${buildDir}/test-results"))

jacocoTestReport {
reports {
html.destination file("${buildDir}/jacocoHtml")
}
}

jpaModelgen {
library = "org.hibernate:hibernate-jpamodelgen"
jpaModelgenSourcesDir="src/jpaModelgen/java"
}

sourceSets {
main {
java {
srcDirs += "src/jpaModelgen/java"
}
}
}


While running the application with `./gradlew build --info` i am getting below error

[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/4TbJY.png

Im using spring-boot 2.2.6, Is there any version compatibility available for hibernate-jpamodelgen.

</details>


# 答案1
**得分**: 0

你不需要使用任何插件来生成JPA元模型。只需要在build.gradle的dependencies块中使用以下代码行即可:

```groovy
annotationProcessor 'org.hibernate.orm:hibernate-jpamodelgen:<6.1.1.Final或其他版本>'
英文:

You don't need to use any plugin to generate JPA metamodel. It is enough to use the line

annotationProcessor &#39;org.hibernate.orm:hibernate-jpamodelgen:&lt;6.1.1.Final now or other version&gt;&#39;

in build.gradle dependencies block.

huangapple
  • 本文由 发表于 2020年4月10日 20:11:05
  • 转载请务必保留本文链接:https://java.coder-hub.com/61139976.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定