【maven】maven 新建项目报错

【问题描述】

报错:

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不能向你配置的本地仓库中储存文件

             6.你配置的插件仓库不支持你需要的插件版本。如果你要使用的是一个镜像版本,要确保settings标签里 不是 <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> 



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码农胖虎-java

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值