问题详细述
公司将一些公共服务封装成了 jar 包部署在了 Maven 私服上。一个新项目需要依赖这些内部 jar 包,在 POM 文件添加了相关依赖,可是却无法下载下来,而且没有报错。
登录私服查看 jar 都在没有问题。通过观察发现没能下载下来的都是 SNAPSHOT 版本的 jar 包, 查询后确认 maven 默认情况下不下载 SNAPSHOT 版本的 jar 包的,想要下载需要进行配置。
解决方法
- 修改settings.xml
<profiles>
<profile>
<!-- 根据仓库id激活下面的配置 -->
<id>xx-nexus</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>xx-nexus</id>
<!-- 私服地址 -->
<url>http://xx.xx.xx.xx:8081/repository/xx_group/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
- 重新 Reimport 依赖