新建SpringBoot项目pom.xml报错:maven-compiler-plugin插件依赖错误

 

报错代码:

Multiple annotations found at this line:
	- CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: PluginResolutionException: Plugin 
	 org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failure to transfer org.codehaus.plexus:plexus-
	 compiler-javac:jar:2.2 from http://maven.aliyun.com/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted 
	 until the update interval of alimaven has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-compiler-
	 javac:jar:2.2 from/to alimaven (http://maven.aliyun.com/nexus/content/groups/public/): Failed to transfer http://maven.aliyun.com/nexus/content/groups/
	 public/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar. Error code 302, Found
	- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin 
	 org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failure to transfer org.codehaus.plexus:plexus-
	 compiler-javac:jar:2.2 from http://maven.aliyun.com/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted 
	 until the update interval of alimaven has elapsed or updates are forced. Original error: Could not transfer artifact org.codehaus.plexus:plexus-compiler-
	 javac:jar:2.2 from/to alimaven (http://maven.aliyun.com/nexus/content/groups/public/): Failed to transfer http://maven.aliyun.com/nexus/content/groups/
	 public/org/codehaus/plexus/plexus-compiler-javac/2.2/plexus-compiler-javac-2.2.jar. Error code 302, Found

在本地库查找了maven-compiler-plugin 和plexus-compiler-javac 的jar包版本都存在,查找另外原因:springBoot 集成jar包里面没有指定maven-compiler-plugin 的jdk的版本,所以 需要 添加jdk 版本指定

 <!-- 指定jdk版本 -->
  <properties>
  	<java.version>1.7</java.version>
  </properties>

资料:https://blog.csdn.net/liupeifeng3514/article/details/80236077

maven是个项目管理工具,如果我们不告诉它我们的代码要使用什么样的jdk版本编译的话,它就会用maven-compiler-plugin默认的jdk版本来进行处理,这样就容易出现版本不匹配,以至于可能导致编译不通过的问题。

maven的默认编译使用的jdk版本貌似很低,使用maven-compiler-plugin插件可以指定项目源码的jdk版本,编译后的jdk版本,以及编码。
 

<plugin>                                                                                                                                      
    <!-- 指定maven编译的jdk版本,如果不指定,maven3默认用jdk 1.5 maven2默认用jdk1.3 -->                                                                           
    <groupId>org.apache.maven.plugins</groupId>                                                                                               
    <artifactId>maven-compiler-plugin</artifactId>                                                                                            
    <version>3.1</version>                                                                                                                    
    <configuration>                                                                                                                           
        <!-- 一般而言,target与source是保持一致的,但是,有时候为了让程序能在其他版本的jdk中运行(对于低版本目标jdk,源代码中不能使用低版本jdk中不支持的语法),会存在target不同于source的情况 -->                    
        <source>1.8</source> <!-- 源代码使用的JDK版本 -->                                                                                             
        <target>1.8</target> <!-- 需要生成的目标class文件的编译版本 -->                                                                                     
        <encoding>UTF-8</encoding><!-- 字符集编码 -->
        <skipTests>true</skipTests><!-- 跳过测试 -->                                                                             
        <verbose>true</verbose>
        <showWarnings>true</showWarnings>                                                                                                               
        <fork>true</fork><!-- 要使compilerVersion标签生效,还需要将fork设为true,用于明确表示编译版本配置的可用 -->                                                        
        <executable><!-- path-to-javac --></executable><!-- 使用指定的javac命令,例如:<executable>${JAVA_1_4_HOME}/bin/javac</executable> -->           
        <compilerVersion>1.3</compilerVersion><!-- 指定插件将使用的编译器的版本 -->                                                                         
        <meminitial>128m</meminitial><!-- 编译器使用的初始内存 -->                                                                                      
        <maxmem>512m</maxmem><!-- 编译器使用的最大内存 -->                                                                                              
        <compilerArgument>-verbose -bootclasspath ${java.home}\lib\rt.jar</compilerArgument><!-- 这个选项用来传递编译器自身不包含但是却支持的参数选项 -->               
    </configuration>                                                                                                                          
</plugin>                                                                                                                                     

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值