[英]Lombok 1.18.2 does not work with maven and jdk 10
Lombok is not creating the getters/setters when i try to compile my Java Projekt under JDK 10. 当我尝试在JDK 10下编译Java Projekt时,Lombok并未创建getter / setter。
The class that uses Lombok annotations. 使用Lombok批注的类。
package com.testcompany.data;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
public class DataInfo {
private Map<String,String> metadata = new HashMap<>();
private String extractedString;
}
Usage of the Lombok annotated class 龙目岛注释类的用法
String test = dataInfo.getExtractedString();
I am using the following versions to compile my sources to java 10: 我正在使用以下版本将源代码编译为Java 10:
pom.xml in the dependency section 依赖项部分中的pom.xml
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
and in the maven-compiler-plugin section 在maven-compiler-plugin部分
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
when I compile via mvn install i get the following error: 当我通过mvn install编译时,出现以下错误:
MemberRegistration.java:[50,36] cannot find symbol
symbol: method getExtractedString()
location: variable dataInfo of type com.testcompany.data.DataInfo
Is there anything i need to do different when using jdk 10? 使用jdk 10时我需要做些不同的事情吗?
Thanks to all! 谢谢大家! The main problem was, that I used the compiler Argument " -proc:none " which means "compilation takes place without annotation processing...".
主要问题是,我使用了编译器参数“ -proc:none ”,这意味着“无需注释处理即可进行编译...”。 So I removed this Argument.
所以我删除了这个论点。 Beside of this, it is also recommended, to use the following compiler arguments (see compilerArgs section):
除此之外,还建议使用以下编译器参数(请参见compilerArgs部分):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>10</source>
<target>10</target>
<release>10</release>
<executable>javac10</executable>
<fork>false</fork>
<encoding>UTF-8</encoding>
<!-- see https://github.com/rzwitserloot/lombok/issues/985#issuecomment-356135454 -->
<compilerArgs>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
<arg>-J--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.2</version>
</path>
</annotationProcessorPaths>
<showWarnings>true</showWarnings>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.