Java NoSuchCompilerException maven包
尝试运行Java NoSuchCompilerException maven包,java,macos,maven,jersey,Java,Macos,Maven,Jersey,尝试运行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:com
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>
4.0.0
com.rest
在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
获得了Java工具,它胜过了$PATH环境,因为它出现在/Library/Java/JavaVirtualMachines/jdk1.8.045.jdk/Contents/Home/bin
之前,为什么要添加plexus编译器api和plexus编译器管理器作为依赖项?这是没有意义的…删除那些依赖项…是的,我对pom中需要包含哪些内容而不是哪些内容感到有点困惑。在我添加它们之前,它也不起作用。感谢@khmarbaisethanks的回复。正如您在.bash\u概要文件中所说的,我将JAVA\u设置为HOME,我还从路径中删除了JAVA\u HOME/bin。我检查了两个“which”命令是否返回正确的路径。我仍然得到同样的错误。您还有其他建议吗?当您在新的终端窗口中键入java-version
和javac-version
时,您会得到什么建议?java版本“1.8.0_45”
java(TM)SE运行时环境(构建1.8.0_45-b14)
java热点(TM)64位服务器虚拟机(构建25.45-b02,混合模式)
javac1.8.0\u45
请将mvn clean package-X的输出添加到您的问题中。我使用您的pom内容构建了一个小测试项目,它在maven 3.0.5、3.1.1、3.2.5和3.3.9中运行良好。我添加了堆栈跟踪。我想我之前没有提到,但我使用的是maven 3.3.9