欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

maven tomcat:run指定tomcat7:

程序员文章站 2022-03-31 23:37:24
...

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

 DelegatingFilterProxy cannot be cast to Filter

 

请在

settings.xml

 

<pluginGroups>
<pluginGroup>org.apache.tomcat.maven</pluginGroup>
</pluginGroups>

 

 

pom.xml

 

<repositories>
    <repository>
      <id>people.apache.snapshots</id>
      <url>http://repository.apache.org/content/groups/snapshots-group/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>apache.snapshots</id>
      <name>Apache Snapshots</name>
      <url>http://repository.apache.org/content/groups/snapshots-group/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

<plugins>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat6-maven-plugin</artifactId>
      <version>2.0-SNAPSHOT</version>
      <configuration>

        <path>/</path>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <artifactId>tomcat7-maven-plugin</artifactId>
      <version>2.0-SNAPSHOT</version>
      <configuration>
        <path>/</path>
      </configuration>
    </plugin>
  </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,去除依赖关系。