eclipse创建maven工程问题总结

一、在eclipse导入maven工程或创建maven工程时,会出现以下错误:

Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:3.1 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be 
 reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:3.1 
 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: 

 sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target


Multiple annotations found at this line:
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read 
artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1: ArtifactResolutionException: Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:
3.1 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are 
forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-compiler-plugin:pom:3.1 from/to central (https://repo.maven.apache.org/maven2): 
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (execution: default-testCompile, phase: test-
compile)
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: Failed to read 
artifact descriptor for org.apache.maven.plugins:maven-compiler-plugin:jar:3.1: ArtifactResolutionException: Could not transfer artifact org.apache.maven.plugins:maven-compiler-
plugin:pom:3.1 from/to central (https://repo.maven.apache.org/maven2): sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (execution: default-compile, phase: compile)


以上基本上是由于网络问题导致连接不到中央库引起。

解决办法1:在pom.xml增加如下配置,替换默认的编译配置


 
       
       maven-compiler-plugin
       3.3
       
         
           default-compile
           compile
           
             compile
           

           
             1.8
             1.8
             UTF-8
           

         

         
           default-testCompile
           test-compile
           
             testCompile
           

           
             1.8
             1.8
             UTF-8
           

         

       

       
         1.8
         1.8
         UTF-8
       

     

   
 


解决方法2:替换仓库位置

修改maven配置文件setting.xml,使用阿里云的镜像

   
alimaven    
aliyun maven    
http://maven.aliyun.com/nexus/content/groups/public/    
central            

修改以上配置后,点击工程右键--Maven--Update Project刷新工程。

你可能感兴趣的:(maven)