开启私服
3.5版本私服直接安装就能使用
nexus.exe /run命令直接运行,不要关闭cmd
上传jar包到私服
1. 把dao模块上传到私服(如果上述setting.xml文件中配置过再次检查是否配置完整正确):
第一步:配置私服地址
1. 在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文件添加:
<!-- 配置远程发布到私服,mvn deploy -->
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
第二步: 运行 deploy命令,不同开发工具会有差异。
如果所有配置正确,发现上传私服失败,需要进入私服找到指定仓库
Repository--- Access Settings--Deployment Policy修改为允许发布
从私服下载jar包
3.service模块从私服下载dao包
1.1、在settings.xml文件中
<profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://localhost:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository>
<!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/repository/maven-public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
2.激活私服
<!-- 激活 -->
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
注意:
私服一般安装在内网的其他服务器上,而不是本机上。因此上面的配置中localhost的部分在实际情况中应该修改为公司中内网的私服服务器地址。