一般私服都搭建在局域网,也就是说在外网没法使用私服了;
如果配置采用mirrors映射到私服,那么在外网时因为私服连接不上,这就悲催了;
后面发现可以通过profile配置私服地址,当处在局域网优先使用私服地址,当处于外网时(私服连接不上的时候),会切换到默认的外网仓库中央仓库(repo.maven.apache.org)。
修改settings.xml配置:
1、profiles节点下增加:
<profile>
<id>public-snapshots</id>
<repositories>
<repository>
<id>public-snapshots</id>
<url>http://10.122.7.92:8081/nexus/content/groups/public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
2、activeProfiles节点下配置激活上面的profile
<activeProfiles>
<activeProfile>public-snapshots</activeProfile>
</activeProfiles>
2018/2/10 GMT+8 下午9:26:56: [INFO] Downloaded http://10.122.7.92:8081/nexus/content/groups/public/com/bbossgroups/bboss-velocity/5.0.3.8.3/bboss-velocity-5.0.3.8.3.jar 2018/2/10 GMT+8 下午9:27:06: [INFO] Downloaded http://10.122.7.92:8081/nexus/content/groups/public/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar 2018/2/10 GMT+8 下午9:27:16: [INFO] Downloaded http://10.122.7.92:8081/nexus/content/groups/public/werken-xpath/werken-xpath/0.9.4/werken-xpath-0.9.4.jar 2018/2/10 GMT+8 下午9:27:18: [INFO] Downloading https://repo.maven.apache.org/maven2/com/bbossgroups/bboss-velocity/5.0.3.8.3/bboss-velocity-5.0.3.8.3.jar 2018/2/10 GMT+8 下午9:27:36: [INFO] Downloaded https://repo.maven.apache.org/maven2/com/bbossgroups/bboss-velocity/5.0.3.8.3/bboss-velocity-5.0.3.8.3.jar 2018/2/10 GMT+8 下午9:27:36: [INFO] Downloading https://repo.maven.apache.org/maven2/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar 2018/2/10 GMT+8 下午9:27:39: [INFO] Downloaded https://repo.maven.apache.org/maven2/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar 2018/2/10 GMT+8 下午9:27:41: [INFO] Downloading https://repo.maven.apache.org/maven2/werken-xpath/werken-xpath/0.9.4/werken-xpath-0.9.4.jar 2018/2/10 GMT+8 下午9:27:52: [INFO] Downloaded https://repo.maven.apache.org/maven2/werken-xpath/werken-xpath/0.9.4/werken-xpath-0.9.4.jar