Maven 打包项目到私服 (deploy)
一、配置maven
在maven安装目录 /conf/setting.xml 中的servers下添加:
1 <servers> 2 <server> 3 <id>nexus-snapshots</id> 4 <username>admin</username> 5 <password>123456</password> 6 </server> 7 <server> 8 <id>nexus-releases</id> 9 <username>admin</username> 10 <password>123456</password> 11 </server> 12 </servers>
二、配置pom
在maven工程的pom.xml配置部署的仓库,注意pom.xml和setting.xml中的id属性要一致
1 <!-- 发布maven私服 --> 2 <distributionManagement> 3 <repository> 4 <id>nexus-snapshots</id> 5 <name>tuohang-framework-SNAPSHOTS</name> 6 <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> 7 </repository> 8 <snapshotRepository> 9 <id>nexus-repository</id> 10 <name>tuohang-framework-REPOSITORY</name> 11 <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> 12 </snapshotRepository> 13 </distributionManagement>
三、使用deploy命令上传
在项目路径下使用命令:
mvn deploy -Dmaven.test.skip=true
或者:mvn deploy:deploy-file -Dmaven.test.skip=true -Dfile=D:\workspace\com.xxx.test-1.0.0.jar -DgroupId=com.xxx -DartifactId=test -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -DrepositoryId=nexus-repository -Durl=http://192.168.xxx.xxx:9090/repository/3rd-part/
如图build success 代表成功。
四、使用
1 <!-- 远程nexus仓库 --> 2 <repositories> 3 <repository> 4 <id>nexus-snapshots</id> 5 <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> 6 </repository> 7 <repository> 8 <id>nexus-repository</id> 9 <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> 10 </repository> 11 </repositories> 12 <pluginRepositories> 13 <pluginRepository> 14 <id>nexus-snapshots</id> 15 <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> 16 </pluginRepository> 17 <pluginRepository> 18 <id>nexus-repository</id> 19 <url>http://47.100.xxx.xxx:30010/repository/3rd-part/</url> 20 </pluginRepository> 21 </pluginRepositories>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!