tomcat-maven-plugin插件为我们在使用Maven进行部署时提供了很大方便。
使用过程中部署正常,但在修改完代码后需要重新部署,如果不对应用程序做一些配置,部署往往失败(我遇到的情况是应用中的某些jar包无法删除干净,导致整个应用不能删除),需要做的配置如下:
1.启用context.xml功能,需要在pom.xml中加入配置,如下:
<plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1</version> <configuration> <mode>both</mode>//设置为both模式,启用context.xml <url>http://localhost:8080/manager</url> <server>myserver</server> <path>/MyApp</path> </configuration> </plugin> </plugins>
2.在src/main/webapp/META-INF下创建context.xml:
<?xml version="1.0" encoding="UTF-8"?> <Context reloadable="true" antiResourceLocking="true"> </Context>