Since the Cachefilter implements the Javax.servlet.Filter interface, filter is in Servlet-api.jar, so the POM has <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> << version>2.4</version> </</span>dependency> But Tomcat already has the SERVLET-API package, and the version may be different, so there will be classcastexception problem "solution" SERVLET-API join provided, as follows: <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> after this modification, Servlet-api.jar will not be in the import when running Tomcat, not with TomcatThe SERVLET-API with the conflict "recommendations to avoid such problems" note the definition of scope for packages in Pom.xml to resolve problems arising from such package conflicts
Maven2 Xxxservlet cannot is cast to Javax.servlet