天天看點

Maven 本地倉庫通路私服

假設我們已經在Nexus伺服器上面已經建構了兩個宿主倉庫:heima-release和heima-snapshots,并且将這兩個宿主倉庫添加到了maven-public群組中

Maven 本地倉庫通路私服
Maven 本地倉庫通路私服

maven-public倉庫組的通路位址為:http://192.168.1.105:8082/repository/maven-public/

Maven 本地倉庫通路私服

接着,我們需要在maven的配置檔案settings.xml 中進行相應的配置

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localRepository>D:\repo</localRepository>

    <pluginGroups>

    </pluginGroups>

    <proxies>

    </proxies>

	<!--配置通路maven私服相關宿主倉庫的使用者名和密碼-->
	<servers>
		<server>
			<id>heima-release</id>
			<username>admin</username>
			<password>123456</password>
		</server>
		<server>
			<id>heima-snapshots</id>
			<username>admin</username>
			<password>123456</password>
		</server>
	</servers>

    <mirrors>
        <mirror>
            <id>nexus-aliyun</id>
            <mirrorOf>central</mirrorOf>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>
		<!--自定義的私服通路-->
        <mirror>
            <id>nexus-heima</id>
            <mirrorOf>*</mirrorOf>
            <url>http://192.168.1.105:8082/repository/maven-public/</url>
        </mirror>
    </mirrors>
	
    <profiles>
    </profiles>
</settings>
           

上述配置說明:如果需要下載下傳相關的依賴資源包,并且屬于中央倉庫(central),則全部會去阿裡雲倉庫查找下載下傳,除此之外的其它依賴資源包才會去私服裡面查找下載下傳。