1.使用 mvn clean package -Dmaven.test.skip=true 命令报错
报错内容如下:
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project
起初认为是pom.xml文件中没有导入compiler,然后设置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
然后重新输入mvn clean package -Dmaven.test.skip=true,发现还是报以上错误。
然后注意到报错内容还有这些:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
便怀疑是否是java版本号设置错误了,但是经过一番查看后,发现都是正确的,一时间不得其解。






后来谷歌一下后,发现需要在setting.xml文件中配置java版本号,并且需要激活它,内容如下:
<profile>
<id>custom-compiler</id>
<properties> <JAVA8_HOME>E:\java\dev</JAVA8_HOME></properties>
</profile>
<activeProfiles>
<activeProfile>custom-compiler</activeProfile>
</activeProfiles>
然后在pom.xml中导入如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA8_HOME}/bin/javac</executable>
</configuration></plugin>
当按住crtl键点击${JAVA8_HOME}能跳转到setting.xml文件中时,说明配置成功,此时执行mvn命令
mvn clean package -Dmaven.test.skip=true,就可以成功打包了!!!

网友评论