关于Maven私服的搭建能够参考我这篇博客:http://www.javashuo.com/article/p-ujmlmhoy-dg.htmlmaven
maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar
maven-releases:私库发行版jar
maven-snapshots:私库快照(调试版本)jar
maven-public:仓库分组,把上面三个仓库组合在一块儿对外提供服务,在本地maven基础配置settings.xml中使用。阿里云
在Maven project中pom.xml文件添加如下信息url
<repositories> <repository> <id>nexus</id> <name>Nexus3 Repository</name> <!-- 此为仓库地址 --> <url>http://192.168.230.129:8081/repository/maven-public/</url> </repository> </repositories>
代码中url
标签的路径在Repositories
中选择须要的仓库,点击URL
字段下的copy
进行复制spa
修改Maven的配置文件settings.xml .net
<profiles> <profile> <id>NexusRepo</id> <repositories> <repository> <id>nexus</id> <name>Nexus3 Repository</name> <url>http://192.168.230.129:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <!-- snapshots默认是关闭的,须要手动开启 --> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>NexusRepo</activeProfile> </activeProfiles>
注: 此种方法若是远程仓库关闭或意外退出,在maven构建时会到中央仓库去查找jar包调试
2.2)setting.xml添加以下信息code
<mirror> <id>nexus-tout</id> <!-- *号表明全部仓库,此处也能够单独设置,以逗号隔开 --> <mirrorOf>*</mirrorOf> <name>Nexus3 tout</name> <url>http://192.168.230.129:8081/repository/maven-public/</url> </mirror>
注:这个方法跟添加阿里云的镜像是同样的,且都会使上面2.1)的配置不生效server
若是想发布项目的jar包,能够配置以下信息:xml
<distributionManagement> <repository> <id>maven-releases</id> <name>maven releases</name> <url>http://192.168.230.129:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>maven-snapshots</id> <name>maven snapshots</name> <url>http://192.168.230.129:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
<servers> <server> <id>maven-releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>maven-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers>
注:上下id必须一致!!blog
而后就能够deploy,构建上传jar包了