Maven 本地仓库访问私服

假设我们已经在Nexus服务器上面已经构建了两个宿主仓库:heima-release和heima-snapshots,并且将这两个宿主仓库添加到了maven-public群组中

maven-public仓库组的访问地址为:http://192.168.1.105:8082/repository/maven-public/

接着,我们需要在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:
epo</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),则全部会去阿里云仓库查找下载,除此之外的其它依赖资源包才会去私服里面查找下载。

经验分享 程序员 微信小程序 职场和发展