1.配置git/svn地址 (读写权限)
<scm>
<connection>scm:git:https://xxxxxxxxxx.git</connection>
<developerConnection>scm:git:https://xxxxxxxxxx.git</developerConnection>
<url>https:xxxxxxxxxxxx/master</url>
</scm>
2.上传地址(可以推送私服)
<distributionManagement>
<repository>
<id>dev.release</id>
<url>file:F:\software\apache-maven-3.2.3-bin\maven\mavenSCM\</url>
</repository>
</distributionManagement>
3.配置release插件scm等
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.5</version>
<configuration>
<connectionType>developerConnection</connectionType>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
//可以写上账号密码也可以去掉打包的时候验证
<!--<username>xxxxxx</username>
<password>xxxxxx</password>-->
<tagBase>https:xxxxxxxxxxxx/tags</tagBase>
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
<!--打包跳过test-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!--打包跳过javadocs-->
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
4.推送tag代码mvn release:prepare,清理mvn release:clean,从tag打包mvn release:perform
5.常用命令mvn scm:update 更新代码和服务器同步。和git的pull效果一样
mvn scm:checkin -Dmessage=""提交代码和git的commit+push一样
mvn scm:diff展现和服务器不同的地方,会有.diff文件查看
mvn scm:validate校验SCM的配置信息是否正确
6.打包推送时有三次命名,重要(第三次命名必须以-SNAPSHOT结尾,maven要求)第一次命名打包名字,第二次tag名字,第三次版本号名字
7.打包推送时mvn release:prepare必须让本地代码和服务器代码同步最新才可以,不然报错。
8.如果你的项目中pom分多个模块,就需要使用命令:release:prepare-with-pom进行打包发布