nosuchcompilerexception maven包

8oomwypt  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(383)

想跑的时候 mvn clean package 我得到以下错误:

Failed to execute goal org.apache.maven.plugins:maven-compiler-
plugin:3.6.0:compile (default-compile) on project rest-webapp: 
Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:
3.6.0:compile failed: A required class was missing while executing 
org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile: 
org/codehaus/plexus/compiler/manager/NoSuchCompilerException

我发现了很多建议,可以删除 ~/.m2/repository . 这样做并不能解决问题。
这是我的pom.xml:

<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.rest</groupId>
<artifactId>rest-webapp</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>rest-webapp</name>

<build>
    <finalName>rest-webapp</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <inherited>true</inherited>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>3.0.2</version>
            <inherited>true</inherited>
        </plugin>   
    </plugins>
</build>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.ow2.asm</groupId>
        <artifactId>asm</artifactId>
        <version>6.0_ALPHA</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-compiler-api</artifactId>
        <version>2.8.1</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-compiler-manager</artifactId>
        <version>2.8.1</version>
    </dependency>
</dependencies>
<properties>
    <jersey.version>2.25</jersey.version>
    <project.build.sourceEncoding>
        UTF-8
    </project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>

我正在使用mac osx 10.11.6
$javau家是 /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home $path是 /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin:/opt/apache-maven-3.3.9/bin 如有任何建议,将不胜感激。
编辑:运行时的堆栈跟踪 mvn clean package -X 发布于:http://pastebin.ca/3753171

35g0bw71

35g0bw711#

在os x中设置命令行java的正确方法是使用:

export JAVA_HOME=`/usr/libexec/java_home -v1.8`

这不仅设置了 JAVA_HOME 环境变量,还可以调整中的一堆链接 /usr/bin 以便:

[steve@Steves-MacBook-Pro ~]$ which java
/usr/bin/java
[steve@Steves-MacBook-Pro ~]$ which javac
/usr/bin/javac

应用于在中指定的版本 /usr/libexec/java_home 呼叫,因此无需添加 $JAVA_HOME/bin 给你的 $PATH .
我猜您从未这样做过,所以您从 /usr/bin 它胜过$path环境,因为它以前出现过 /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin .

相关问题