zoukankan      html  css  js  c++  java
  • 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

    背景:本项目使用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)Javajdk1.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)Javajdk1.8.0_73injavac  

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

    揭晓原因:

    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

  • 相关阅读:
    设计模式学习总结系列应用实例
    【研究课题】高校特殊学生的发现及培养机制研究
    Linux下Oracle11G RAC报错:在安装oracle软件时报file not found一例
    python pro practice
    openstack python sdk list tenants get token get servers
    openstack api
    python
    git for windows
    openstack api users list get token get servers
    linux 流量监控
  • 原文地址:https://www.cnblogs.com/louby/p/10758825.html
Copyright © 2011-2022 走看看