[2022-04-27 09:28:32,807] Artifact bookitem:war: Artifact is being deployed, please wait... 27-Apr-2022 09:28:33.239 警告 [RMI TCP Connection(3)-127.0.0.1] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0]. Default version will be used. 27-Apr-2022 09:28:34.127 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 27-Apr-2022 09:28:34.167 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file 27-Apr-2022 09:28:34.168 严重 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Context [/bookitem_war] startup failed due to previous errors [2022-04-27 09:28:34,182] Artifact bookitem:war: Error during artifact deployment. See server log for details.
找到filter中的init
删Filter.super.init(filterConfig);
即:
原因:
如图我的错误原因是因为filter的相关方法错误,经排查发现我使用的Filter是4.0.1版本的,其中init()和destroy()方法使用了default关键字,该关键字为JDK1.8的新特性,意思是子类不必一定实现该方法。
所以自定义的MyFilter类仅覆盖了doFilter方法,但Tomcat服务器上的Filter类的init()和destroy()方法没有使用default关键字,就导致自定义的MyFilter类必须覆盖这两个方法, 于是就产生了冲突。