为什么 spring 调度程序加载两次?
Why the spring scheduler is loading twice?
最近,我遇到了与调度程序相关的问题,因为它加载了两次。我付出了很多努力来解决它但无法修复它。我发现与此问题相关的每个问题都说这是与 spring as scheduler load twice 相关的问题,如果您使用的是最新版本,它将得到解决,但我不这么认为。有人可以告诉我这个问题吗,这样我就可以解决它。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<error-page>
<!-- Missing login -->
<error-code>401</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Forbidden directory listing -->
<error-code>403</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Missing resource -->
<error-code>404</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Uncaught exception -->
<error-code>500</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Unsupported servlet method -->
<error-code>503</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/v1/login.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/v1/login.xhtml</location>
</error-page>
<display-name>IN UI</display-name>
<welcome-file-list>
<welcome-file>/v1/login.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/v1/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
<init-param>
<param-name>ExpiresByType image</param-name>
<param-value>access plus 10 minutes</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType text/css</param-name>
<param-value>access plus 10 minutes</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType application/javascript</param-name>
<param-value>access plus 10 minutes</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-servlet.xml
</param-value>
</context-param>
<context-param>
<param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
<param-value>6LedGUAUAAAAAGap-5zdfoh_uEVC6ccuf_oL61Be</param-value>
</context-param>
<context-param>
<param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
<param-value>6LedGUAUAAAAAK6rMd7J1LDq-utm55Oc3mo645im</param-value>
</context-param>
javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE
真的
com.sun.faces.config.ConfigureListener
org.springframework.web.context.ContextLoaderListener
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/xml</mime-type>
</mime-mapping>
好的,我在 web.xml
中发现了一些问题,因为您两次加载上下文,一次使用 Request Context Listener,一次使用 Dispatcher Servlet 。我认为没有必要在加载 Dispatcher Servlet 时加载 Request Context Listener 所以请从 web.xml
中删除它:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
它将解决您的问题。有关详细信息,请参阅:contextloaderlistener vs dispatcherservlet
最近,我遇到了与调度程序相关的问题,因为它加载了两次。我付出了很多努力来解决它但无法修复它。我发现与此问题相关的每个问题都说这是与 spring as scheduler load twice 相关的问题,如果您使用的是最新版本,它将得到解决,但我不这么认为。有人可以告诉我这个问题吗,这样我就可以解决它。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<error-page>
<!-- Missing login -->
<error-code>401</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Forbidden directory listing -->
<error-code>403</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Missing resource -->
<error-code>404</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Uncaught exception -->
<error-code>500</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<!-- Unsupported servlet method -->
<error-code>503</error-code>
<location>/v1/error.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/v1/login.xhtml</location>
</error-page>
<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/v1/login.xhtml</location>
</error-page>
<display-name>IN UI</display-name>
<welcome-file-list>
<welcome-file>/v1/login.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/v1/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
<init-param>
<param-name>ExpiresByType image</param-name>
<param-value>access plus 10 minutes</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType text/css</param-name>
<param-value>access plus 10 minutes</param-value>
</init-param>
<init-param>
<param-name>ExpiresByType application/javascript</param-name>
<param-value>access plus 10 minutes</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-servlet.xml
</param-value>
</context-param>
<context-param>
<param-name>primefaces.PUBLIC_CAPTCHA_KEY</param-name>
<param-value>6LedGUAUAAAAAGap-5zdfoh_uEVC6ccuf_oL61Be</param-value>
</context-param>
<context-param>
<param-name>primefaces.PRIVATE_CAPTCHA_KEY</param-name>
<param-value>6LedGUAUAAAAAK6rMd7J1LDq-utm55Oc3mo645im</param-value>
</context-param>
javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE 真的 com.sun.faces.config.ConfigureListener org.springframework.web.context.ContextLoaderListener
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<mime-mapping>
<extension>xhtml</extension>
<mime-type>application/xml</mime-type>
</mime-mapping>
好的,我在 web.xml
中发现了一些问题,因为您两次加载上下文,一次使用 Request Context Listener,一次使用 Dispatcher Servlet 。我认为没有必要在加载 Dispatcher Servlet 时加载 Request Context Listener 所以请从 web.xml
中删除它:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
它将解决您的问题。有关详细信息,请参阅:contextloaderlistener vs dispatcherservlet