Caused by: java.lang.ClassNotFoundException: com.sun.tools.javac.code.TypeTags when using lombok

前端 未结 9 1645
一整个雨季
一整个雨季 2020-11-28 11:44

I have following dependency in pom.xml:


    org.projectlombok
    lombok

        
相关标签:
9条回答
  • 2020-11-28 12:32

    I always managed to resolve this issue with numerous old projects using older version of Lombok by simply upgrading the Lombok version

    With this upgrade of Lombok; for projects with heavy memory during test running phases I have also had to start specifying memory configurations for maven-surefire-plugin which generally seems to now need more memory to avoid Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test failed: The forked VM terminated without properly saying goodbye. VM crash or System.exit called? errors

    See below for example working pom.xml configs

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    
      </properties>
        ...
        <lombok.version>1.18.2</lombok.version>
        ...
      </properties>
    
      <dependencies>
        ...
        <dependency>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok</artifactId>
          <version>${lombok.version}</version>
          <scope>provided</scope>
        </dependency>
        ...
      </dependencies>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <!--Extra memory to prevent jvm crash during heavy Integration/unit test with newer lombok and jdk8-->
              <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
            </configuration>
          </plugin>
        ...
        </plugins>
      </build>
    </project>
    
    0 讨论(0)
  • 2020-11-28 12:33

    my project uses java1.8,and this problem have be solved by using lombok 1.18.4.

    0 讨论(0)
  • 2020-11-28 12:34

    This happened with me when I installed maven with brew which also installed Java.15.x that leads to this error.

    To validate, add debug option -X while building with maven and check the Java version that maven is using.

    Delete the Java.15x directory and set JAVA_HOME in your .bashrc with the correct version of Java.

    0 讨论(0)
提交回复
热议问题