【问题描述】

报错:

Could not calculate build plan: Pluginorg.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependenciescould not be resolved: Failed to read artifact descriptor fororg.apache.maven.plugins:maven-resources-plugin:jar:2.5 

Pluginorg.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependenciescould not be resolved: Failed to read artifact descriptor fororg.apache.maven.plugins:maven-resources-plugin:jar:2.5

【官网提示】

This erroroccurs when you employ a plugin that Maven could not download. Possible causesfor this error are:

  1. You are referring to a non-existing plugin, e.g. by means of a typo in its group id, artifact id or version.
  2. You are using a third-party Maven plugin that is not deployed to the central Maven repository and your POM/settings is missing the required <pluginRepository> to download the plugin. Note that <repository> declarations are not considered when looking for the plugin and its dependencies, only <pluginRepositories> are searched for plugins.
  3. The plugin repository you have configured requires authentication and Maven failed to provide the correct credentials to the server. In this case, make sure your${user.home}/.m2/settings.xml contains a <server> declaration whose <id> matches the <id> of the plugin repository to use. See the Maven Settings Reference for more details.
  4. There is a general network problem that prevents Maven from accessing any remote repository, e.g. a missing proxy configuration.
  5. Maven failed to save the files to your local repository, see LocalRepositoryNotAccessibleException for more details.
  6. The plugin repository you have configured is disabled for the specific version of the plugin you requested. For instance, if you want to use a SNAPSHOT version of a plugin, make sure you don't have <snapshots><enabled>false</enabled></snapshots> configured. Likewise, in order to resolve a released version of the plugin, the plugin repository should not be configured with <releases><enabled>false</enabled></releases>. See the POM Reference for more information on repository configuration.

【翻译】 

            主要就是说拉去不了jar包,具体官网给出了6种可能:

             1. 你引用了一个不存在的插件

             2.你引用了一个第三方maven插件,中央仓库里没有。

             3.你配置的远程仓库需要认证,但是你没有权限

             4.网络问题,你连接不到远程仓库

             5.maven不能向你配置的本地仓库中储存文件

<snapshots><enabled>false</enabled></snapshots> 同样,<releases><enabled>false</enabled></releases>.这个也不行。

  


【解决方案】

       我出现这个错误的原因是Settings 里没有配置中央仓库,之前做项目时只配置了私服,本地没有的jar包都是由私服拉取的。 这会自己敲例子用到的jar包私服上没有,于是就出现了这个错误。配置好中央仓库就没问题了。

<repositories>  
                    
                <!--包含需要连接到远程仓库的信息  -->  
                <repository>  
                        
                    <!--远程仓库唯一标识 -->  
                    <id>central</id>  
                        
                    <!--远程仓库名称  -->  
                    <name>Central</name>  
                        
                    <!--如何处理远程仓库里发布版本的下载 -->  
                    <releases>  
                            
                        <!--true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。   -->  
                        <enabled>false</enabled>  
                            
                        <!--该元素指定更新发生的频率。Maven会比较本地POM和远程POM的时间戳。这里的选项是:-->  
                        <!--always(一直),daily(默认,每日),interval:X(这里X是以分钟为单位的时间间隔),或者never(从不)。  -->  
                        <updatePolicy>always</updatePolicy>  
                            
                        <!--当Maven验证构件校验文件失败时该怎么做:-->  
                        <!--ignore(忽略),fail(失败),或者warn(警告)。 -->  
                        <checksumPolicy>warn</checksumPolicy>  
                               
                    </releases>  
                        
                    <!--如何处理远程仓库里快照版本的下载。有了releases和snapshots这两组配置,POM就可以在每个单独的仓库中,为每种类型的构件采取不同的策略。-->  
                    <!--例如,可能有人会决定只为开发目的开启对快照版本下载的支持。参见repositories/repository/releases元素 -->  
                    <snapshots>  
                                
                        <enabled />  
                        <updatePolicy />  
                        <checksumPolicy />  
                               
                    </snapshots>  
                        
                    <!--远程仓库URL,按protocol://hostname/path形式  -->  
                    <url>http://repo.maven.apache.org/maven2</url>  
                        
                    <!--用于定位和排序构件的仓库布局类型-可以是default(默认)或者legacy(遗留)。-->  
                    <!--Maven 2为其仓库提供了一个默认的布局;然而,Maven 1.x有一种不同的布局。我们可以使用该元素指定布局是default(默认)还是legacy(遗留)。  -->  
                    <layout>default</layout>  
                          
                </repository>  
                     
            </repositories>