1、修改tomcat下的tomcat-user.xml文件,加入
<role rolename="manager"/>
<user username="admin" password="123456" roles="manager"/>,启动tomcat后用admin/123456登陆http://127.0.0.1:8080/mamager/html 测试其可用性
2、在您需要部署的应用的pom.xml中加入
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<url>http://127.0.0.1:8080/manager</url>
<server>tomcat</server>
<path>/spring3JDBC</path>
</configuration>
</plugin>
其中<server>tomcat</server>需要和下面的setting.xml中的server一致,<path>/spring3JDBC</path>是虚拟目录
3、修改全局maven的setting.xml文件
<server>
<id>tomcat</id>
<username>admin</username> <!--tomcat用户名和密码--->
<password>123456</password>
</server>
4、运行maven
mvn clean 清理应用包
mvn test 测试包完整性
mvn package 打应用包
mvn install 将打出的应用包安装到本地仓库
mvn tomcat:deploy(undeploy stop start) 操作tomcat
5、分发构件至远程仓库 在需要部署的应用的pom.xml中加入 <project> ... <distributionmanagement><repository><id>nexus-releases</id><name>Nexus Release Repository</name><url>http://127.0.0.1:8080/nexus/content/repositories/releases/</url></repository><snapshotrepository><id>nexus-snapshots</id><name>Nexus Snapshot Repository</name><url>http://127.0.0.1:8080/nexus/content/repositories/snapshots/</url></snapshotrepository></distributionmanagement> ... </project> 在maven全局配置中加入 <settings> ... <servers><server><id>nexus-releases</id><username>admin</username><password>admin123</password></server><server><id>nexus-snapshots</id><username>admin</username><password>admin123</password></server></servers> ... </settings> 运行mvn deploy后,当应用pom.xml中<version>0.0.1-SNAPSHOT</version>则打出的构建将分发到快照目录http://192.168.198.132:8081/nexus/content/repositories/snapshots/下,并自动加上日期作为版本号,第一次编译编译号为01,别人使用的时候默认取得最新的一个应用包;当应用pom.xml中<version>1.0.0</version>没有SNAPSHOT时,将分发到http://192.168.198.132:8081/nexus/content/repositories/releases/下