一、启动nexus
1.登录
2.添加release仓库
3.添加snapshot仓库
4.配置maven-public
能看到自定义仓库东西
二、配置客户端settings.xml
防止每次创建项目maven重置异常
settings.xml配置
仓库位置
<localRepository>C:\maven-repository</localRepository>
server
id: 名字不能重复,和pom引入名称相同
username/password: nexus的登录用户名密码
<server>
<id>wnhz</id>
<username>admin</username>
<password>123</password>
</server>
<server>
<id>wnhz-releases</id>
<username>admin</username>
<password>123</password>
</server>
<server>
<id>wnhz-snapshots</id>
<username>admin</username>
<password>123</password>
</server>
mirror
url:是nexus的maven-public
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>maven</id>
<mirrorOf>*</mirrorOf>
<name>maven私服仓库</name>
<url>http://192.168.201.81:8081/repository/maven-public/</url>
</mirror>
profile
- jdk版本
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
<profile>
- nexus仓库配置
<profile>
<!--profile 的 id-->
<id>nexus</id>
<repositories>
<repository>
<!--仓库 id,repositories 可以配置多个仓库,保证 id 不重复-->
<id>nexus</id>
<!--仓库地址,即 nexus 仓库组的地址-->
<url>http://192.168.72.131:8081/repository/maven-public/</url>
<!--是否下载 releases 构件-->
<releases>
<enabled>true</enabled>
</releases>
<!--是否下载 snapshots 构件-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- 插件仓库,maven 的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository>
<!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://192.168.72.131:8081/repository/maven-public/</url>
<!--是否下载 releases 构件-->
<releases>
<enabled>true</enabled>
</releases>
<!--是否下载 snapshots 构件-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
activeprofile
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
开发使用maven部署
pom中部署maven
<distributionManagement>
<snapshotRepository>
<id>wnhz-snapshots</id>
<url>http://192.168.72.131:8081/repository/wnhz-snapshots/</url>
</snapshotRepository>
<repository>
<id>wnhz-releases</id>
<url>http://192.168.72.131:8081/repository/wnhz-releases/</url>
</repository>
</distributionManagement>
<repositories>
<repository>
<id>nexus</id>
<url>http://192.168.72.131/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>