有几次返回了401、400等错误,一般都是settings.xml和pom.xml配置不正确。
保证settings.xml正确
- 一般运维搭建好私服之后,就有配置地址了,可以从其他人那拷贝
识别repository的URL
- pom.xml设置,需要找到自己要deploy上去的repository,一般分为snapshots和releases
- 打开nexus的主页,点左边菜单的repositories,找到自己要deploy的目标repo
修改自己的pom.xml,注意:
- id一定要是settings.xml里server的id,并且保证权限足够大
- name随意取,方便查看即可,甚至可以去掉
- url一定要找到nexus上的repositories的地址,不要搞混了snapshots和releases,否则也会失败
<distributionManagement>
<repository>
<id>nexus</id>
<name>releases</name>
<url>http://192.180.0.37:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<name>snapshots</name>
<url>http://192.180.0.37:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
deploy到nexus
- 直接用IDEA的插件就可以
- 先install打包,再deploy,稍等片刻就成功了(我第一次以为失败了,第一步卡着等了好一会儿,耐心等等吧)
验证
-
命令行显示成功
-
nexus私服上找到自己的jar
使用
- 我先new了一个demo里面的类,但是maven找不到(不知道为啥)
- 尝试在pom.xml里先添加依赖之后,就可以找到了
<dependency>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.2-release</version>
</dependency>
mincong-h.github.io/2018/08/04/… www.jianshu.com/p/2ef1642b7… blog.csdn.net/haoui123/ar… blog.csdn.net/wo541075754…