- 在开发环境中,我配置好了自己的私服nexus, 里面阿里云,geo等等的资源库代理都写好了, 按理说只要连上我们的私服, 公共的jar包下载应该不是问题, 但是发现还是下载不了maven-compiler-plugin等等 的maven插件
- 经过测试研究发现,maven的 pluginRepositories 属性没有配置, 如果不写pluginRepositories ,plugins还是走默认的maven仓库, repositories 和 pluginRepositories 都写好之后, 全部都会从私服下载了.
<distributionManagement>
<repository>
<id>SES Releases</id>
<name>SES Releases</name>
<url>http://192.168.168.198:2019/repository/ses-releases</url>
</repository>
<snapshotRepository>
<id>SES Snapshots</id>
<name>SES Snapshots</name>
<url>http://192.168.168.198:2019/repository/ses-snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>SES_Repositories</id>
<name>SES_Repositories</name>
<url>http://192.168.168.198:2019/repository/ses/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<!--opc-->
<!--<repository>
<id>openscada-repo</id>
<url>http://neutronium.openscada.org/maven/</url>
</repository>-->
</repositories>
<pluginRepositories>
<pluginRepository>
<id>SES_Plugin_Repositories</id>
<name>SES_Plugin_Repositories</name>
<url>http://192.168.168.198:2019/repository/ses/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
- 需要注意的一点maven setting.xml 配置文件中 mirror这个配置
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
注意maven下载的流程
- 找pom的repository, 确定远程仓库地址
- 找到settings.xml文件, mirror这个配置, mirror相当于一个拦截器, 按照上面的写法, 所有的jar请求都转到aliyun去了,就不会再去私服下载了,
- 所以要注意mirror这一点, 所有的请求代理都应该在nexus私服创建好, 不要让mirror 把请求带跑偏了.开发人员打开项目就行,不需要自己再配置mirror.