在 maven pom.xml 中直接使用阿里云镜像


maven pom.xml 中直接使用阿里云镜像

仅仅在 maven settings.xml 中添加本地仓库,项目中单独配置阿里云镜像

<!-- 配置阿里云仓库 -->
<repositories>
    <repository>
        <id>aliyun-repos</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>aliyun-repos</id>
        <url>https://maven.aliyun.com/repository/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

注: <repositories> 标签控制 maven 依赖下载的镜像地址,<pluginRepositories> 标签控制 maven 插件的下载镜像地址,如果其中一个没配置,那么默认依旧使用默认的仓库地址。

个人想法:这样的好处是,项目团队共同开发的时候,直接拉取代码就好,不用单独配置本地 maven 配置文件,如果多个项目共同使用一个 maven 配置文件,可能不方便,如果涉及到自己搭建的私服,不同项目的私服地址可能不一样。项目用什么就配置什么,灵活点。

补充:

  • setting.xml:该文件配置的是全局模式

  • pom.xml:该文件的配置的是项目独享模式

    注意:若 pom.xmlsetting.xml 同时配置了,以 pom.xml 为准。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM