• maven报 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile(defalut-compile) on project 项目名称:No such compile 'javac'


         这个问题纠结了一天,在另外一个电脑是正常的,但是从服务器下载下来到另外一个电脑的时候却出现了如下图问题

    看到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>  
  • 相关阅读:
    FastJson 配置Long转String类型 , 解决前后端交互, id过长,失去精度的问题
    idea使用技巧大全
    多线程下载工具
    https url 下载
    Jquery ajax请求格式
    AQS之可重入锁ReentrantLock原理
    整理所学之HashMap | 第二篇
    数据结构:哈希表例子
    整理所学之HashMap | 第一篇
    设计模式 | 第三篇:装饰者模式
  • 原文地址:https://www.cnblogs.com/a757956132/p/5945055.html
Copyright © 2020-2023  润新知