使用Maven自动部署Java Web项目到Tomcat问题小记

不过我的问题都不是上面两个,我的问题是自动部署命令写错了,应该是mvn tomcat7:deploy命令,而我之前用的是mvn tomcat:deploy命令


tomcat-users.xml

<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>


maven/config/ settings.xml

<server>
<id>myserver</id>
<username>admin</username>
<password>admin</password>
</server>


<!-- tomcat7插件 -->
<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>myserver</server>
<path>/${project.artifactId}</path>
<update>true</update>
<username>admin</username>
<password>admin</password>
<update>true</update>
<uriEncoding>UTF-8</uriEncoding>
</configuration>
</plugin>


“Application already exists at path”问题 使用tomcat7-maven-plugin插件部署到tomcat服务器时,当服务器上已经有相同名字的项目就会导致
FAIL - Application already exists at path ...
解决方法是在pom.xml文件中配置tomcat7-maven-plugin插件时加入参数update

“web.xml which will be ignored ”问题 在使用Maven 编译项目的时候会出现:

[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')

解决方法是添加下面这样一个plugin即可:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.1.1</version>
  <configuration>
     <packagingExcludes>WEB-INF/web.xml</packagingExcludes>
  </configuration>
</plugin>

猜你喜欢

转载自blog.csdn.net/u014755645/article/details/69062858
今日推荐