今天花了点时间研究了下Nexus,做个小笔记。
1.别忘了登录 =..= 默认为admin/admin123;
2.修改proxy类型的仓库配置,将Download Remote Indexes改为True,save后会下载索引比较慢;
3.修改Public Repositories的配置,选几个仓库组合,然后就用这个仓库组的url了;
4.本机的maven/conf/setting.xml要加2段配置:
=======================================================
<settings>
...
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://<address>:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
=======================================================
如果不改这个也可以,改项目POM,添加:
<project>
...
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>public</id>
<name>Public Repositories</name>
<url>http://192.168.1.100:8081/nexus/content/groups/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>Public Repositories</name>
<url>http://192.168.1.100:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
...
</project>
=======================================================
5.用mvn help:system试试,项目目录下的mvn clean compile...一堆命令试试;
6.如果有获取之类的问题,确认下仓库的Remote Storage Location。我就是这里费了不少力气,不知道是不是网络不给力。
=======================================================
后记:我发现在网通网络连接中央仓库经常失败,电信网络基本没问题,这上面折腾了不少时间,同学们别走弯路了。