【Java】web.xml 里配置了 ContextLoaderListener,tomcat就无法启动

系统:Mac OS
Tomcat版本:8.0.29
web.xml 配置如下:

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.5"

xmlns="http://java.sun.com/xml/ns/javaee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<!-- 编码过滤 -->

<filter>

<filter-name>encodingFilter</filter-name>

<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

<init-param>

<param-name>encoding</param-name>

<param-value>UTF-8</param-value>

</init-param>

</filter>

<filter-mapping>

<filter-name>encodingFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

<!-- spring listener -->

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

<!-- spring -->

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:spring/applicationContext.xml</param-value>

</context-param>

<!-- SpringMVC -->

<servlet>

<servlet-name>springmvc</servlet-name>

<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

<init-param>

<param-name>contextConfigLocation</param-name>

<param-value>classpath:springmvc/spring-mvc.xml</param-value>

</init-param>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>springmvc</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>

</web-app>

运行Tomcat就卡住不动了:
【Java】web.xml 里配置了 ContextLoaderListener,tomcat就无法启动

但是把下面这句注释掉:

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

就能运行了,但是会报org.springframework.beans.factory.BeanCreationException错误。
这是什么原因呢?

回答

初步判断你项目问题,还有没有日志发来看看

请问,这个解决了吗?我也遇到同样的问题。。。

以上是 【Java】web.xml 里配置了 ContextLoaderListener,tomcat就无法启动 的全部内容, 来源链接: utcz.com/a/89064.html

回到顶部