第三方jar发布
打开命令行进入到maven安装目录下的bin目录,敲入如下指令,具体参考根据情况修改,下面有参数详细说明。
1 2 3 4 5 6 7 8 9
| mvn deploy: deploy-file -DgroupId=hw.vedioicon -DartifactId=vedioicon -Dversion=1.0 -Dpackaging=jar -Dfile=D:\workspace\web-mooc\src\main\webapp\WEB-INF\lib\vedioicon.jar -Durl=http://host:port/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
|
- DgroupId和DartifactId构成了该jar包在pom.xml的坐标,项目就是依靠这两个属性定位。自己起名字也行。
- Dfile表示需要上传的jar包的绝对路径。
- Durl私服上仓库的位置,打开nexus——>repositories菜单,可以看到该路径。
- DrepositoryId服务器的表示id,在nexus的configuration可以看到。
- 上传成功后,在nexus界面点击3rd party仓库可以看到这包。
项目发布
pom配置:
1 2 3 4 5 6 7 8 9 10 11
| <distributionManagement> <repository> <id>releases</id> <url>http://host:port/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>nexus distribution snapshot repository</name> <url>http://host:port/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
|
项目右键 run-maven-build 在goal中填写deploy直接运行即可
权限配置:在用户或maven的配置settings.xml,注意如果用户下.m2中配置了settings,以.m2中的为主
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <servers> <server> <id>releases</id> <username>deployment</username> <password>******</password> </server> <server> <id>snapshots</id> <username>deployment</username> <password>******</password> </server> <server> <id>thirdparty</id> <username>deployment</username> <password>******</password> </server> </servers>
|
注意id一定要和server中的id统一
参考链接:https://my.oschina.net/geekLight/blog/424206