Maven pom.xml中添加指定的中央仓库

中央仓库就是Maven的一个默认的远程仓库,Maven的安装文件中自带了中央仓库的配置($M2_HOME/lib/maven-model-builder.jar)

在很多情况下,默认的中央仓库无法满足项目的需求,可能项目需要的jar包存在另一个远程仓库中,这时就可以在pom.xml文件中配置仓库,代码如下:

 

<repositories>
    <repository>
        <!-- Maven 自带的中央仓库使用的Id为central 如果其他的仓库声明也是用该Id
        就会覆盖中央仓库的配置 --> 
      <id>mvnrepository</id>
        <name>mvnrepository</name>
        <url>http://www.mvnrepository.com/</url>
        <layout>default</layout>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

 

 

原文地址:https://www.cnblogs.com/sos-blue/p/5867019.html