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,去除依賴關系。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM