maven报 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile(defalut-com
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven报 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile(defalut-com相关的知识,希望对你有一定的参考价值。
这个问题纠结了一天,在另外一个电脑是正常的,但是从服务器下载下来到另外一个电脑的时候却出现了如下图问题
看到javac大家都会想到是编译出现问题,而本地的配置如下图所示:
看着配置都是一致的,会是哪里的问题呢?经网上咨询有个大神说是可能是maven没有配置指定的jdk原因,原因如下:
maven是个项目管理工具,如果我们不告诉它我们的代码要使用什么样的jdk版本编译的话,它就会用maven-compiler-plugin默认的jdk版本来进行处理,这样就容易出现版本不匹配的问题,以至于可能导致编译不通过的问题。为了处理这一种情况的出现,在构建maven项目的时候,我习惯性第一步就是配置maven-compiler-plugin插件。解决办法:
在pom.xml中指定使用的版本 1 <build>
2 <plugins> 3 <plugin> 4 <groupId>org.apache.maven.plugins</groupId> 5 <artifactId>maven-compiler-plugin</artifactId>
<!-- 使用3.5.1也是正确 不知道为啥 如果是3.0就是错误的,但是maven里面也有3.0的版本,可能跟我电脑安装的maven版本有关,本地按照maven版本为3.0.5 -->
6 <version>3.1</version> 7 <configuration> 8 <defaultLibBundleDir>lib</defaultLibBundleDir> 9 指定高版本的源码和编译后的字节码文件 10 <source>1.6</source> 11 <target>1.6</target> 12 <optimize>true</optimize> 13 <debug>true</debug> 14 <showDeprecation>true</showDeprecation> 15 <showWarnings>true</showWarnings> 16 <encoding>UTF-8</encoding> 17 </configuration> 18 </plugin> 19 20 </plugins> 21 </build>
经过指定后,电脑可以正常运行了。
问题2:
1 [WARNING] 2 [WARNING] Some problems were encountered while building the effective model for com.xxx.xxx:xxxx:jar:0.0.1-SNAPSHOT 3 [WARNING] ‘build.plugins.plugin.version‘ for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 72, column 12 4 [WARNING] 5 [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build. 6 [WARNING] 7 [WARNING] For this reason, future Maven versions might no longer support building such malformed projects. 8 [WARNING]
对照官网用法:http://maven.apache.org/plugins/maven-compiler-plugin/usage.html
起初配置:
1 <plugins> 2 <plugin> 3 <artifactId>maven-compiler-plugin</artifactId> 4 <configuration> 5 <source>1.6</source> 6 <target>1.6</target> 7 <encoding>UTF-8</encoding> 8 </configuration> 9 </plugin> 10 </plugins>
该问题解决办法是需要置顶maven版本,解决办法:
1 <plugins> 2 <plugin> 3 <artifactId>maven-compiler-plugin</artifactId> 4 <version>3.0</version> 5 <configuration> 6 <source>1.6</source> 7 <target>1.6</target> 8 <encoding>UTF-8</encoding> 9 </configuration> 10 </plugin> 11 </plugins>
以上是关于maven报 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile(defalut-com的主要内容,如果未能解决你的问题,请参考以下文章
thingsboard 2.4.3 编译报错Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.5.0:
thingsboard 2.4.3 编译报错Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.5.0:
Springboot项目Maven打包报错:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:r
maven clean install命令报错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:
maven打包报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.2.RELEASE:repa
maven打包报错Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.5.2.RELEASE:repa