简体   繁体   中英

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile)

There is a small project on microservices.

Java 14

root pom.xml

<groupId>ru.booking</groupId>
<artifactId>booking</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.12</version>
    <relativePath/>       
</parent>
<modules>
    <!-- MicroService -->
    <module>authentication</module>
    <module>content-service</module>
    <module>common</module>
</modules>

module authentication pom.xml

<parent>
    <artifactId>booking</artifactId>
    <groupId>ru.booking</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>authentication</artifactId>
<version>1.0-SNAPSHOT</version>
<name>authentication</name>
<description>Authentication MicroService</description>
<properties>
    <java.version>14</java.version>
    <maven.compiler.source>14</maven.compiler.source>
    <maven.compiler.target>14</maven.compiler.target>       
    <jwt.version>3.13.0</jwt.version>
    <lombok.version>1.18.18</lombok.version>
    <common.version>1.0-SNAPSHOT</common.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>ru.booking</groupId>
        <artifactId>common</artifactId>
        <version>${common.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.auth0</groupId>
        <artifactId>java-jwt</artifactId>
        <version>${jwt.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.4.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

module content-service pom.xml

<parent>
    <artifactId>booking</artifactId>
    <groupId>ru.booking</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>content-service</artifactId>
<version>1.0-SNAPSHOT</version>
<name>content-service</name>
<description>Service MicroService</description>
<properties>
    <java.version>14</java.version>
    <maven.compiler.source>14</maven.compiler.source>
    <maven.compiler.target>14</maven.compiler.target>       
    <lombok.version>1.18.18</lombok.version>
    <common.version>1.0-SNAPSHOT</common.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>ru.booking</groupId>
        <artifactId>common</artifactId>
        <version>${common.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.4.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

the common module - in this module there will be only all sorts of data structures (for example enum)

pom.xml

<parent>
    <artifactId>booking</artifactId>
    <groupId>ru.booking</groupId>
    <version>1.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
<name>common</name>
<description>common MicroService</description>
<properties>
    <java.version>14</java.version>
    <lombok.version>1.18.18</lombok.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>${lombok.version}</version>
        <optional>true</optional>
    </dependency>
</dependencies>

run

mvn clean install

and in the common module I get an error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project common: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed
 module @0x202ae86f) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x202ae86f ->
[Help 1]

I understand that he is not friends with lombok, but where does this version of the maven-compiler-plugin come from:3.8.1, if I have version 2.4.2 listed everywhere?

I looked at similar questions, they mostly advise to manually register the maven-compiler-plugin version, I have it registered.

Check your java version. I just had the same problem, solved it by changing my JAVA_HOME from jdk17 to jdk1.8

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM