1. 在eclipse配置tomcat,部署路径设置为tomcat的webapps目录下。
2.修改tomcat-users.xml
<!-- Tomcat 6.x 系列-->
<role rolename="manager"/>
<user password="admin" roles="manager" username="admin"/>
<!-- Tomcat 7.x 系列-->
<role rolename="manager"/>
<role rolename="manager-script"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="pass!@#" roles="manager,manager-gui,admin-gui,manager-script"/>
3. maven的settings.xml 文件打开,写入用户名和密码
<servers>
<server>
<id>tomcat</id>
<username>admin</username>
<password>pass!@#</password>
</server>
</servers>
4.pom文件为:
< build > < finalName > dounine-frame </ finalName > < plugins > < plugin > < groupId > org.apache.maven.plugins </ groupId > < artifactId > maven-compiler-plugin </ artifactId > < version > 3.1 </ version > < configuration > < source > 1.7 </ source > < target > 1.7 </ target > < encoding > UTF-8 </ encoding > </ configuration > </ plugin > < plugin > < groupId > org.apache.maven.plugins </ groupId > < artifactId > maven-war-plugin </ artifactId > < version > 2.1.1 </ version > </ plugin > < plugin > < groupId > org.apache.tomcat.maven </ groupId > < artifactId > tomcat6-maven-plugin </ artifactId > < version > 2.0 </ version > < configuration > <!-- Tomcat 6.x --> < url > http://localhost:8080/manager/ </ url > <!-- Tomcat 7.x --> <!-- <url>http://localhost:8080/manager/text</url> --> < server > tomcat </ server > <!-- 这个server标签里面的值(tomcat)要和你的setting.xml里面的id的值(tomcat)一致 --> < username > admin </ username > < password > admin </ password > < path > /dounine-frame </ path > </ configuration > </ plugin > </ plugins > < resources > < resource > < directory > src/main/java </ directory > < includes > < include > **/*.xml </ include > </ includes > </ resource > < resource > < directory > src/main/resources </ directory > < includes > < include > *.* </ include > </ includes > </ resource > </ resources > </ build >
5.启动tomcat
6.在eclipse中:tomcat6.x使用 tomcat6:redeploy。