1.修改mavne的配置文件settings.xml 在profiles标签中,添加如下profile
<!-- 开发环境 (snapshots环境) --></span>
<profile>
<id>mydev</id>
<properties>
<repository.id>mydev</repository.id>
<repository.name>myDev Repository</repository.name>
<repository.url>http://admin:123456@192.168.1.101/content/repositories/snapshots/</repository.url>
</properties>
</profile>
<!-- 正式环境(releases环境) --></span>
<profile>
<id>production</id>
<properties>
<repository.id>production</repository.id>
<repository.name>Production Repository</repository.name>
<repository.url>http://admin:123456@192.168.1.101/content/repositories/releases/</repository.url>
</properties>
</profile>
2.在项目的pom.xml里面添加
<distributionManagement>
<repository>
<id>${repository.id}</id>
<name>${repository.name}</name>
<url>${repository.url}</url>
<layout>default</layout>
</repository>
</distributionManagement>
3.mvn clean deploy -Pproduction 表示deploy到正式环境
mvn clean deploy -Pdev 表示deploy到开发环境
mvn clean deploy -Pproduction 表示deploy到正式环境