1.tomcat方面的配置
在tomcat文件夹下找到conf/tomcat-users.xml 在
<tomcat-users></tomcat-users>
下
添加role 和user
<role rolename="tomcat"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="tomcat,manager-gui,admin-gui,manager-script"/>
role决定user的权限,maven upload war到tomcat需要权限
2.maven方面的配置
maven setting.xml 有两种,一种是User Level (用户级别),这个setting.xml 一般是${user.home}/.m2/settings.xml
另一种是Global Level(全局级别)这个xml是在maven安装文件夹conf下
安装maven时默认没有User Level setting.xml,需要拷贝conf/setting.xml到${user.home}/.m2/下
然后在setting.xml下添加
<server>
<id>localhost</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
3.maven项目下pom.xml的配置
tomcat官网有相应的文档,http://tomcat.apache.org/maven-plugin-2.2/
<pluginManagement> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>localhost</server>
<path>/WebDemo</path>
</configuration>
</plugin>
</plugins>
</pluginManagement>
tomcat6和tomcat7配置差别较大,
verison | groupid | url |
tomcat6 | org.codehaus.mojo | http://localhost:8080/manager |
tomcat7 | org.appache.tomcat.maven | http://localhost:8080/manager/text |
4.部署maven项目
启动tomcat,右键点击maven项目,选择maven build 设置Goals为 tomcat7:deploy ,