How coxxist lombok and JPAMetalModel processors with maven

How to use Lombok when the JPAMetaModelEntityProcessor annotation handler is activated in the maven assembly.

Maven configuration:

[...] <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> </compilerArguments> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <scope>provided</scope> </dependency> <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <scope>provided</scope> </dependency> </dependencies> [...] 

During the build process (mvn clean install), MetaModel objects are generated correctly, but it seems that the Lombok comment processor is not added to the Javac compilation. All @Getter, @Setter, ... do not work.

+8
java maven jpa lombok
source share
3 answers

After viewing the lombok project, I found a solution.

When specifying JPAMetaModelEntityProcessor as the javac annotation processor, the lombok processor seems remote.

To fix this, we can simply add the Lombok comment handler to the maven-compiler-plugin:

 [...] <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor,lombok.launch.AnnotationProcessorHider$AnnotationProcessor</processor> </compilerArguments> </configuration> </plugin> [...] 
+18
source share

@Pierrick's solution is right. but I can offer this solution. because we can add many processors with this.

 <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessorPaths> <path> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> </path> <path> <groupId>org.hibernate</groupId> <artifactId>hibernate-jpamodelgen</artifactId> <version>5.4.1.Final</version> </path> </annotationProcessorPaths> </configuration> </plugin> 
+1
source share

Solution if @Pierrick is not quite right. You must reorder the processors.

 <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <compilerArguments> <processor> lombok.launch.AnnotationProcessorHider$AnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor </processor> </compilerArguments> </configuration> </plugin> 
0
source share

All Articles