maven 配置本地倉庫、中央倉庫、私庫


1.准備條件

  找到maven的安裝目錄--》conf目錄--》settings.xml文件,例如:D:\apache-maven-3.5.3\conf

2.倉庫配置

  第一,本地倉庫

  找到settings標簽,緊挨着它就是被注釋掉的localRepository標簽,在這個位置配置<localRepository></localRepository>並設置倉庫位置即可。例如:

<!-- 指定maven本地倉庫位置 -->
<localRepository>D:\repository-maven</localRepository>  

  第二,中央倉庫

  找到mirrors標簽,緊挨着它就是被注釋掉的mirror標簽,在這個位置配置<mirror></mirror>並設置倉庫位置即可。例如:

<!-- 指定中央倉庫 -->
<mirror> 
    <id>alimaven</id> 
    <name>aliyun maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <!-- <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> -->
    <mirrorOf>central</mirrorOf> 
</mirror>

  第三,私庫

  找到profiles標簽,緊挨着它就是被注釋掉的profile標簽,在這個位置配置<profile></profile>並設置倉庫位置。例如:

<!--私服倉庫配置-->  
<profile>    
    <id>profile-nexus</id>
    <repositories>    
        <repository>    
            <id>nexus</id>    
            <url>http://192.168.57.182:8081/nexus/content/groups/public/</url>
            <snapshots><enabled>true</enabled></snapshots>    
            <releases><enabled>true</enabled></releases>    
        </repository>    
    </repositories>    
    <pluginRepositories>    
        <pluginRepository>    
            <id>nexus</id>    
            <url>http://192.168.57.182:8081/nexus/content/groups/public/</url>    
            <snapshots><enabled>true</enabled></snapshots>    
            <releases><enabled>true</enabled></releases>    
        </pluginRepository>    
    </pluginRepositories>    
</profile>

  並且,需要在profiles標簽體外添加activeProfiles標簽,引用該私服

</profiles>
<!--私服倉庫配置-->
<activeProfiles>    
    <activeProfile>profile-nexus</activeProfile>
    <activeProfile>nexus</activeProfile>
</activeProfiles>

  jar包下載順序:

  本地倉庫--》nexus私服倉庫--》線上的中央倉庫   

 

寫在最后

  哪位大佬如若發現文章存在紕漏之處或需要補充更多內容,歡迎留言!!!

 相關推薦:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM