maven tomcat:run指定tomcat7:

配置好下面的内容后,执行 run as -> tomcat7:run 或者tomcat6:run可以将maven的web应用在tomcat6/7里面运行 ,eclipse Indigo 版本默认tomcat:run是用tomcat6。

 DelegatingFilterProxy cannot be cast to Filter

请在

settings.xml

Xml代码  收藏代码
  1. <pluginGroups>  
  2. <pluginGroup>org.apache.tomcat.maven</pluginGroup>  
  3. </pluginGroups>  

pom.xml

Xml代码  收藏代码
  1. <repositories>  
  2.     <repository>  
  3.       <id>people.apache.snapshots</id>  
  4.       <url>http://repository.apache.org/content/groups/snapshots-group/</url>  
  5.       <releases>  
  6.         <enabled>false</enabled>  
  7.       </releases>  
  8.       <snapshots>  
  9.         <enabled>true</enabled>  
  10.       </snapshots>  
  11.     </repository>  
  12.   </repositories>  
  13.   
  14.   <pluginRepositories>  
  15.     <pluginRepository>  
  16.       <id>apache.snapshots</id>  
  17.       <name>Apache Snapshots</name>  
  18.       <url>http://repository.apache.org/content/groups/snapshots-group/</url>  
  19.       <releases>  
  20.         <enabled>false</enabled>  
  21.       </releases>  
  22.       <snapshots>  
  23.         <enabled>true</enabled>  
  24.       </snapshots>  
  25.     </pluginRepository>  
  26.   </pluginRepositories>  
  27.   
  28. <plugins>  
  29.     <plugin>  
  30.       <groupId>org.apache.tomcat.maven</groupId>  
  31.       <artifactId>tomcat6-maven-plugin</artifactId>  
  32.       <version>2.0-SNAPSHOT</version>  
  33.       <configuration>  
  34.   
  35.         <path>/</path>  
  36.       </configuration>  
  37.     </plugin>  
  38.     <plugin>  
  39.       <groupId>org.apache.tomcat.maven</groupId>  
  40.       <artifactId>tomcat7-maven-plugin</artifactId>  
  41.       <version>2.0-SNAPSHOT</version>  
  42.       <configuration>  
  43.         <path>/</path>  
  44.       </configuration>  
  45.     </plugin>  
  46.   </plugins  

 过程中遇到了一个情况,就是打成war包放到webapps下面运行时正常 的,但是用tomcat:run会报错:org.springframework.web.filter.DelegatingFilterProxy cannot be cast to javax.servlet.Filter;

检查一下:

pom.xml文件编辑器(一般要装插件才能看到)下面的dependency hierarchy 里面,在右边框图里面找到servlet-api.jar,选中后在左边,右键->exclude maven artifact,去除依赖关系。

原文地址:https://www.cnblogs.com/zhaoxinshanwei/p/5769379.html