Maven发布jar包到私库
首先修改maven的配置文件settings.xml,增加servers标签,配好maven服务器的账号密码
1 <servers> 2 <server> 3 <id>releases</id> 4 <username>admin</username> 5 <password>******</password> 6 </server> 7 <server> 8 <id>snapshots</id> 9 <username>admin</username> 10 <password>******</password> 11 </server> 12 <server> 13 </servers>
然后修改pom.xml,增加distributionManagement标签发布管理
1 <!--配置私服仓库--> 2 <distributionManagement> 3 <repository> 4 <id>releases</id> 5 <url>http://172.31.255.207:8180/nexus/content/repositories/releases</url> 6 </repository> 7 <snapshotRepository> 8 <id>snapshots</id> 9 <url>http://172.31.255.207:8180/nexus/content/repositories/snapshots</url> 10 </snapshotRepository> 11 </distributionManagement>
打包时,maven会根据pom文件中配置的version标签是否带了后缀-SNAPSHOT做决定,如果带了-SNAPSHOT就发布到snapshots仓库,否则发布到release仓库。
1 <version>0.0.1-SNAPSHOT</version>