问题描述:
最近发现使用nexus之后,居然有的依赖还是去http://repo.maven.apache.org/maven2/下载:
Downloaded from central: http://repo.maven.apache.org/maven2/...
那我配的私服岂不是白配了。
注意日志是从“central”这个id下载的,说明你的maven配置文件没有配置id为central的repository。
我一看,果然我写的nexus的repository的id是自定义的,不是central这个值。
问题解决:
直接改maven配置setting.xml,把repository的id改成central:
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>你的nexus地址</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>你的nexus地址</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>你的nexus地址</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
然后 mvn package测试,果然都去我私服下载了~~