猿问

mvn install为Lombok属性的@Getter @Setter属性产生编译错误

我在测试我的应用程序时遇到了这个问题,mvn测试将无法运行,并且特别在具有Lombok的@Getter @Setter注释的属性上会产生编译问题。IDE中没有突出显示错误,因为Intelij插件可以工作,但是maven不能以某种方式找到Lombok。我见过与我的问题相似的帖子,但所有帖子都有不同版本的maven / lombok / maven-compiler。我的版本是Maven-3.5,Maven编译器-3.7,Lombok 1.16.20。


我的带有龙目岛注释的Java类


@JsonProperty

@Getter @Setter private String name;



@JsonProperty

@Getter @Setter private String catType;



@JsonProperty

@Getter @Setter private String description;



@JsonProperty

@Getter @Setter private String intType;



@JsonProperty

@Getter @Setter private String numberCode;

当我运行mvn install我得到


> [my-path]/my-java.java:[86,29] cannot find symbol

[ERROR]   symbol:   method numberCode()

[ERROR]   location: variable source of type My-java

[my-path]/my-java.java:[86,29] cannot find symbol

[ERROR]   symbol:   method name()

[ERROR]   location: variable source of type My-java

[my-path]/my-java.java:[86,29] cannot find symbol

[ERROR]   symbol:   method catType()

[ERROR]   location: variable source of type My-java

[my-path]/my-java.java:[86,29] cannot find symbol

[ERROR]   symbol:   method description()

[ERROR]   location: variable source of type My-java 

这是我的Pom.xml(因为这是一个很长的pom.xml,我只分享了在此问题中可能重要的内容)


    <lombok.version>1.18.0</lombok.version>

 <maven-clean-plugin.version>2.6.1</maven-clean-plugin.version>

        <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>

        <maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>

        <maven-enforcer-plugin.version>3.0.0-M1</maven-enforcer-plugin.version>

        <maven-resources-plugin.version>3.0.1</maven-resources-plugin.version>

        <maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>

          <maven.version>3.0.0</maven.version>

        <java.version>1.8</java.version>

        <scala.version>2.12.1</scala.version>

        <node.version>v8.9.4</node.version>

        <yarn.version>v1.3.2</yarn.version>



拉丁的传说
浏览 420回答 3
3回答

DIEA

在看到@DarrenForsythe的评论后,我从maven-compiler的配置中删除了mapstruct注解ProcessorPaths。如果您使用的其他注释处理器可能会导致冲突

小怪兽爱吃肉

您是否在pom.xml文件中添加了项目lombok依赖项?如果尚未完成,请尝试添加:&nbsp;<dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.projectlombok</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>lombok</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>1.16.20</version>&nbsp; &nbsp; &nbsp; &nbsp; </dependency>看看是否有帮助。
随时随地看视频慕课网APP

相关分类

Java
我要回答