admin管理员组文章数量:1389768
I need some help with lombok maven. I am using VSCode. I have the following dependency and plugin in my root pom.xml
:
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<plugin>
<groupId>.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.30</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
While editing in VSCode, there are no problems, the imports are resolved, the @Setter
and @Getter
annotations have no errors, and the references to the getter and setter methods are resolved with no errors. But my actual build of the project is run on command line only (not inside VSCode). When I run mvn compile
, I get symbol not found errors on all of the setter and getter calls.
I've seen several forum posts that say you can't just add lombok dependency and plugin statements - you have to "install" lombok in the IDE. I did that, and it appears to be fine inside VSCode. I found one post that said to "add" lombok to maven by downloading the lombok jar and running:
mvn install:install-file -Dfile=lombok.jar -DgroupId=.projectlombok -DartifactId=lombok -Dversion=1.18.30 -Dpackaging=jar
I did that (it said "SUCCESS"), but there didn't appear to be any change. I'm still getting errors.
What else do I need to do to make maven recognize and use lombok when running maven compiles on the command line?
I need some help with lombok maven. I am using VSCode. I have the following dependency and plugin in my root pom.xml
:
<dependency>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<plugin>
<groupId>.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>1.18.30</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
</plugin>
While editing in VSCode, there are no problems, the imports are resolved, the @Setter
and @Getter
annotations have no errors, and the references to the getter and setter methods are resolved with no errors. But my actual build of the project is run on command line only (not inside VSCode). When I run mvn compile
, I get symbol not found errors on all of the setter and getter calls.
I've seen several forum posts that say you can't just add lombok dependency and plugin statements - you have to "install" lombok in the IDE. I did that, and it appears to be fine inside VSCode. I found one post that said to "add" lombok to maven by downloading the lombok jar and running:
mvn install:install-file -Dfile=lombok.jar -DgroupId=.projectlombok -DartifactId=lombok -Dversion=1.18.30 -Dpackaging=jar
I did that (it said "SUCCESS"), but there didn't appear to be any change. I'm still getting errors.
What else do I need to do to make maven recognize and use lombok when running maven compiles on the command line?
Share Improve this question edited Mar 20 at 19:42 Anerdw 2,0913 gold badges16 silver badges40 bronze badges asked Mar 13 at 15:14 Jerry MalcolmJerry Malcolm 111 bronze badge 01 Answer
Reset to default 2I think that your plugin definition is wrong. The lombok annotation processing needs to be added to the maven-compiler-plugin
<plugin>
<groupId>.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
Alternatively you need to change the phase of your .projectlombok plugin to something earlier than compile
to be sure it fires before the java compile. Most likely generate-sources
本文标签: javaUse lombok with maven without an IDEStack Overflow
版权声明:本文标题:java - Use lombok with maven without an IDE - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744694069a2620169.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论