修改 settings.xml
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<id>nexus-releases</id>
<mirrorOf>nexus</mirrorOf>
<name>nexus releases</name>
<url>http://127.0.0.1:8081/repository/maven-releases/</url>
</mirror>
<mirror>
<id>nexus-central</id>
<mirrorOf>*</mirrorOf>
<name>nexus maven</name>
<url>http://127.0.0.1:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<id>nexus</id>
<name>nexus-snapshots</name>
<url>http://127.0.0.1:8081/repository/maven-central/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>
修改pom.xml
注意此时的version是0.0.1-SNAPSHOT
<parent>
<artifactId>parent</artifactId>
<groupId>com.project</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>0.0.1-SNAPSHOT</version>
<artifactId>base-project</artifactId>
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
<name>Nexus Snapshot</name>
<url>http://127.0.0.1:8081/repository/maven-snapshots/</url>
</snapshotRepository>
<site>
<id>nexus</id>
<name>Nexus Sites</name>
<url>dav:http://127.0.0.1:8081/repository/maven-snapshots/</url>
</site>
</distributionManagement>
maven会自动打上时间戳
如图
deploy不会有时间戳的办法
继续修改pom.xml
把0.0.1-SNAPSHOT改为0.0.1-RELEASE
上传到maven-releases
<parent>
<artifactId>lanxingman-parent</artifactId>
<groupId>com.lanxingman.project</groupId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>0.0.1-RELEASE</version>
<artifactId>lanxingman-base-project</artifactId>
<distributionManagement>
<repository>
<id>nexus</id>
<name>Nexus Snapshot</name>
<url>http://127.0.0.1:8081/repository/maven-releases/</url>
</repository>
</distributionManagement>
结果如下图所示
或者是把版本直接写成0.0.1进行打包deploy
SNAPSHOT版本是快照保本–不稳定,尚处于开发中的版本,maven会自动加时间戳
RELEASE 发布版本–稳定版本