编译致命错误:java.lang.Il legalAccessError:class lombok.javac.apt.LombokProcessor

问题描述 投票:0回答:2

我已经安装了Lombok并获取了最新的Java,将所有系统变量设置为M2或MAVEN和JAVA_HOME。还是有错误。 POM 构建正常,所有文件(例如 mvnw 和 mvnw.cmd)运行良好。但是当我尝试通过 mvn clean install 运行全部内容时,出现了失败:

mvn clean install
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------------< com.aegon:aegon >---------------------------
[INFO] Building aegon 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ aegon ---
[INFO] Deleting C:\Users\48512\Desktop\BEST\BEST\17 KV\projekty\dostałem-rozpakowane\system-biletowy-backend-master\target
[INFO] 
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ aegon ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 57 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ aegon ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 50 source files to C:\Users\48512\Desktop\BEST\BEST\17 KV\projekty\dostałem-rozpakowane\system-biletowy-backend-master\target\classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.672 s
[INFO] Finished at: 2022-08-26T10:54:35+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project aegon: Fatal error compiling: java.lang.Il
legalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x6f4adaab) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironm
ent (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x6f4adaab -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

这是我的 pom.xml (aegon) 文件:

<?xml version="1.0" encoding="UTF-8"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.7.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.aegon</groupId>
    <artifactId>aegon</artifactId>
    <version>1.0</version>
    <name>aegon</name>
    <description>karnavauli 2.0</description>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.2.6</version>
        </dependency>


        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.9.1</version>
        </dependency>


        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.3.5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>

        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>core</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-mail</artifactId>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

如果您需要更多信息,请写信。 我昨天一直在寻找解决方案,但没有任何改变。 另外,这不是我自己的项目,我接手了,我仍在等待与作者的会面,但他说它应该可以正常工作,没有任何问题。事实并非如此。我懂一点Java,但不懂react和springboot。 请帮忙。

java reactjs maven pom.xml
2个回答
2
投票

您的 Spring Boot 版本相当旧。升级到最新的吧。如果不能,请在 pom.xml 中明确提供最新版本的 lombok,而不是使用 springboot 默认使用。

<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
   <groupId>org.projectlombok</groupId>
   <artifactId>lombok</artifactId>
   <version>1.18.24</version>
   <scope>provided</scope>
</dependency>

0
投票
you can solve with this dependency adding in pom file
<dependency>
   <groupId>org.projectlombok</groupId>
   <artifactId>lombok</artifactId>
   <version>1.18.24</version>
   <scope>provided</scope>
</dependency>
© www.soinside.com 2019 - 2024. All rights reserved.