目录
一、问题描述
二、解决办法
解决方式(1)
解决方式(2)
一、问题描述
项目每次打包的时候,都要联网加载maven仓库(或私服),从仓库中下载jar包或者标题中提到的maven-metadata.xml文件。明明本地仓库中依赖包都有还是下载,导致每次打包的时候如果网络不好或者没网的时候就打不了包了或者卡很久才跳过去,搞的我很烦燥。

二、解决办法
解决方式(1)
据说把IDEA的maven设置改成offline就可以了(Eclipse同理)

解决方式(2)
虽然(1)有的人说有效,但是我感觉对我来说无效,于是尝试了另外一种方式,修改maven的配置文件settings.xml文件,在<profile>标签中会配置更新政策,我们只需要将updatePolicy改为never即可.

含义: always:每次,never:从不,daily:每天

示例如下:

<profile>
    <id>myrepo</id>
    <repositories>
        <repository>
            <id>nexus-snapshots</id>
            <url>http://我的私服地址</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <!--<updatePolicy>always</updatePolicy>-->
                <updatePolicy>never</updatePolicy>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus-releases</id>
            <url>http://我的私服地址</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <!--<updatePolicy>always</updatePolicy>-->
                <updatePolicy>never</updatePolicy>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
</profile>

按照这个方式修改完之后,项目基本就不下载了,直接打包,除了项目的CAS模块以外的其他模块都是离线打包(使用本地仓库),看样子行之有效,至于为啥CAS模块还在下载,目前还不清楚,先留个眼,啥时候解决了再更新,或者有大佬知道的,可以指点一下!!!
 

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐