一、上传
1、maven的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添加
<distributionManagement>
<!--id要和私服中配置的server名字一致-->
<repository>
<id>releases</id>
<name>User Project Release</name>
<url>http://ip:port/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>User Project SNAPSHOTS</name>
<url>http://ip:port/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<!-- 要将源码放上去,需要加入这个插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
3、依此执行maven的clean,compile,package,deploy命令
注意:每次发布时 注意jar版本号(pom中version)
二、下载
1、
<dependency>
<groupId>上传到私服项目的groupId</groupId>
<artifactId>上传到私服项目的artifactId</artifactId>
<version>上传到私服项目的version</version>
</dependency>
<repositories>
<repository>
<id>local-nexus</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://ip:port/nexus/content/groups/public/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://localhost:8084/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>