文章目录
一、关于maven私服
1.安装
2.启动
访问:http://localhost:8081/nexus
3.解释
二、maven私服的使用
1.将项目发布到maven私服
P225 25-maven私服将项目发布到maven私服)
1.配置maven的settings.xml文件
<!-- 配置用户名密码开始 -->
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<!-- 配置用户名密码结束 -->
2.配置项目的pom.xml文件
<!--添加到要上传的项目pom中确定上传路径开始-->
distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<!--添加到要上传的项目pom中确定上传路径结束-->
3.执行mvn deploy命令
4.注意点
你不是配置了两个地方吗,这两个地方的配置配置信息存在对应关系
2.从私服下载jar到本地仓库
学习视频:P226 26-maven私服(从私服下载jar到本地仓库)
1.在maven的settings.xml文件中配置下载模板
<!--配置私服下载jar包的模板 开始-->
<profile>
<!--profile的id-->
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<!--仓库地址,即nexus仓库组的地址-->
<url>http://localhost:8081/nexus/content/groups/public/</url>
<!--是否下载releases构件-->
<releases>
<enabled>true</enabled>
</releases>
<!--是否下载snapshots构件-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository>
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<!--配置私服下载jar包的模板 结束-->
2.在maven的settings.xml文件中配置激活下载模板
<!--激活下载模板 开始-->
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
<!--激活下载模板 结束-->
3.执行
3.将第三方jar安装到maven本地仓库
4.将第三方jar安装到maven私服
感谢浏览和收藏