I have a Spring Boot project using maven. It uses 4 plugins for build with maven-compiler-plugin:
- hibernate-jpamodelgen to generate the JPA meta-model (Entity_)
- mapstruct-processor for mappers
- lombok & lombok-mapstruct-binding for getters en setters, constructors, ...
However when I use mvn clean package
to create an executable jar, compilation fails because metamodel classes were not generated. Instead I get a bunch of "cannot find symbol" with the target EntityClassNames_.
Mapstruct is generating the mappers in the target\generated-sources\annotation
, but there's nothing about metamodels. I don't understand why metamodels sources are not generated. Has anyone any clue on this? Any pom.xml working with these?
If I build the project from eclipse classes are well generated, but it does not work directly from command line with maven.
My Java version is 11, and hibernate-jpamodelgen is 5.4.29.Final
Here is the build section from my pom.xml :
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${lombok-mapstruct-binding.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Unlike other issues I don't have error on the hibernate-jpamodelgen itself, I don't know if it is really executed or not. It looks like it is not generating the sources it should.
I tried the suggestions from other threads with no luck.
I created a simple project with the same pom.xml and an entity and metamodel works.