用nexus搭建maven仓库的,为了解决Maven本地仓库没有Jar包问题,请求中央仓库自动下载以及手动下载方法,方法如下:
第一步、修改maven的配置文件settings.xml中的镜像
<mirrors>
<mirror>
<!--阿里云镜像-->
<id>nexus</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
第二步、修改maven的配置文件settings.xml中的profile信息
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://localhost:9091/repository/maven-central/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled><updatePolicy>always</updatePolicy></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2//</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
第三、当使用maven创建项目时,本地仓库的没有的jar包,如何让中央仓库自动下载:
1.打开maven资源的官方网站search.maven.org/
2.搜索需要的jar包
3.选择版本
4.找到相应jar包的坐标代码
5.把复制的代码粘贴到 pom.xml文件中
6.更新maven项目,就可以自动下载相应的jar到本地仓库了