背景:本项目使用JDK1.8

编译maven工程的时候出现如下错误:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1

pom中如下配置maven插件,配置中声明使用JDK1.8:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${JAVA8_HOME}/bin/javac</executable>
</configuration>
</plugin>

这里的${JAVA8_HOME}这个变量是在settings.xml中配置的,如下:

<profile>
<id>custom-compiler</id>
<properties>
<JAVA8_HOME>C:\Program Files (x86)\Java\jdk1.8.0_73</JAVA8_HOME>
</properties>
</profile>

当然这里应该需要激活,所以settings.xml文件还应该有如下配置:

<activeProfiles>
<activeProfile>custom-compiler</activeProfile>
</activeProfiles>

从pom文件中CTRL点击变量JAVA8_HOME能跳到settings.xml中找到它的定义处,按理来说应该是能找到这个变量,出现上述问题并不是因为找不到这个变量。我将pom文件中的JAVA8_HOME这个变量直接用实际的路径替换,即替换为

C:\Program Files (x86)\Java\jdk1.8.0_73\bin\javac

发现编译通过,这就奇怪了。

揭晓原因:

maven其实是有一个默认的仓库.m2仓库和默认的settings.xml配置文件,我们在这个默认的settings.xml文件中也添加了一个JAVA8_HOME的变量后,编译就通过了,这就说明,maven编译的时候找的不是我在idea中配置的我自定义的settings.xml,而是先找的它默认的那个。因为里面没有,所以之前找不到JAVA8_HOME,导致编译失败、

总结:maven编译的时候应该是先找的默认的settings.xml,如果找不到,才会去找我在idea的settings选项下配置的“User settings file”中配置的settings.xml文件。

解决办法:删掉maven默认的去找的那个settings.xml文件,这样自定义的文件就会生效了

原文:https://www.cnblogs.com/telwanggs/p/7016570.html

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project demo: Fatal error com piling: 无效的标记: -parameters的更多相关文章

  1. maven install Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang

    maven打包成war时,报错:Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default- ...

  2. Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (dist) on project hadoop-kms: An Ant BuildException has occured

    编译cdh版hadoop2.5.0出现的问题 系统: CentOs66 64位 JDK:1.7 Maven: 3.0.5 Protobuf: libprotoc 2.5.0 编译命令: mvn pac ...

  3. Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project LogTest: Compilation failure -> [Help 1]

      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default ...

  4. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:

    security-sdk-1.0.jar已经存在于D:/secServerSDK-test/src/main/resources/lib下 报错如下: xxxxxx@xxxxxxxx /d/secSe ...

  5. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (default-cli) on project standalone-pom: Unable to parse configuration of 3: mojo org.apache.maven.plugins:

    问题: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4:create (defau ...

  6. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (default-jar) on

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-jar-plugin:2.3.1:jar (default-jar) on ...

  7. maven install 报错Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project*****

    [ERROR]Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-co ...

  8. Maven Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean Failed to delete access_log

    I'm trying to run simple struts project using maven and tomcat. When I'm trying to exucute next goal ...

  9. 解决Failed to execute goal org.apache.maven.plugins

    1.Maven构建失败 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin: 2.3 . 2 :compile  ...

随机推荐

  1. [机器学习入门篇]-Logistic函数与Softmax函数

    1.Logistic函数 在维基百科中,对logistic函数这样介绍道: A logistic function or logistic curve is a common "S" ...

  2. DOM操作技术

    1.动态script function loadScript(url) { var script = document.createElement("script"); scrip ...

  3. redis:hash哈希类型的操作

    1. hash哈希类型的操作 1.1. hset key field value 语法:hset key field value 作用:把key中field域的值设为value 注:如果没有field ...

  4. css3 学习 重点 常用

    1 -webkit-    -moz-   -o-浏览器兼容 2 box-sizing:border-box;   两个近乎一样的div一样的样式 平分一个div  定义:属性允许您以确切的方式定义适 ...

  5. learning to generate question headlines 讲座

    渣排版预警! 出发点 新闻用户为什么会点: 主观:用户兴趣/热点事件 客观:新闻标题(新闻入口)/新闻内容(更简单,更有趣) 标题分类: surprise,好奇,负例,数字,你,客观的描述,问题的形式 ...

  6. JS_高程7.函数表达式(1)

    定义函数的两种常见的方法: 1 . 函数声明 2. 函数表达式 # 差异 (1)函数声明 ,具有函数声明提升的特征. (2)函数声明的函数的name属性为函数的名称:使用函数表达式定义的函数在ES5中 ...

  7. GMA Round 1 新年祝福

    传送门 新年祝福 15个人聚集在一起,新年到来,他们每个人写下了一句新年祝福.大家把祝福收集起来,然后重新分回去.如果一个人拿到了自己写的祝福,他就会觉得很没有意思,因为得不到别人的祝福.要避免这种尴 ...

  8. 微信小程序生成指定页面小程序码海报图片分享思路总结

    本博客主要说下思路,具体代码不贴 1.考虑到组件复用,所以我把它做成一个自定义的组件 <my-poster id="getPoster" avater="{{ima ...

  9. shell编程学习笔记(七):Shell中将指定内容输出到文件中

    我们这里把echo要打印的内容输出到文件中 以下蓝色字体部分为Linux命令,红色字体的内容为输出的内容: # cd /opt/scripts # vim script06.sh 开始编写script ...

  10. centos7.0安装cuda驱动

    00.CUDA简介 CUDA和GPU的并行处理能力来加速深度学习和其他计算密集型应用程序 01.CPU+GPU协同架构 02.部署环境 [docker@lab-250 ~]$ cat /etc/*re ...