在 Maven 中配置 hibernate-jpamodelgen [英] Configure hibernate-jpamodelgen in Maven
本文介绍了在 Maven 中配置 hibernate-jpamodelgen的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将 hibernate-jpamodelgen 配置到 Maven POM 文件中.我试过这个:
I want to configure hibernate-jpamodelgen into Maven POM file. I tried this:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>plugin</groupId>
<artifactId>org.plugin</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Plugin</name>
<url>http://maven.apache.org</url>
<parent>
........
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.3.Final</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>datalis_plugin</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>10</source>
<target>10</target>
<encoding>${project.build.sourceEncoding}</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
</path>
</annotationProcessorPaths>
<compilerArguments>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
完整 POM:https://pastebin.com/VjucMAYL
但我得到错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project org.plugin: Compilation failure
[ERROR] Annotation processor 'org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor' not found
你知道我该如何解决这个问题吗?我很喜欢这个:https://docs.jboss.org/hibernate/jpamodelgen/1.0/reference/en-US/html_single/
D you know how I can fix this issue? I used this quite: https://docs.jboss.org/hibernate/jpamodelgen/1.0/reference/en-US/html_single/
推荐答案
Remove
from
Remove <scope>provided</scope>
from
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.3.Final</version>
</dependency>
添加插件
<plugins>
...
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.4.3.Final</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
然后重建
mvn clean package -DskipTests
这篇关于在 Maven 中配置 hibernate-jpamodelgen的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文