开发者社区> 问答> 正文

HSF+spring+maven 总是报ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

昨天还能启动,今天就报错了,找不到spring加载配置文件的监听器。报错:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

image

Pandora正常启动

image

web.xml配置

br> "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<display-name>model</display-name>

<!-- Spring的配置文件 -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring-*.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener
    </listener-class>
</listener>
<listener>
    <listener-class>
        org.springframework.web.context.request.RequestContextListener
    </listener-class>
</listener>
<!-- 防止Spring内存溢出监听器 -->
<listener>
    <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>

<!-- 编码过滤器 -->
<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <async-supported>true</async-supported>
    <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>

maven确认已经加入了

image
目录
image

用普通的tomcat能正常启动,用alitomcat就找不到监听器,spring无法启动。。。用官网的hsf示例启动也是报同样的错,昨天我还能启动呢,今天就启动不了了,搞了一天了,有人遇到过这样的情况吗

展开
收起
potatomato 2018-12-04 17:49:15 7268 0
1 条回答
写回答
取消 提交回答
  • 打印一下依赖树,检查一下新引入的包,是否包含springboot等基础包的引用,把相关的引用排掉就可以了

    2019-07-17 23:18:14
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
云栖社区特邀专家徐雷Java Spring Boot开发实战系列课程(第20讲):经典面试题与阿里等名企内部招聘求职面试技巧 立即下载
微服务架构模式与原理Spring Cloud开发实战 立即下载
阿里特邀专家徐雷Java Spring Boot开发实战系列课程(第18讲):制作Java Docker镜像与推送到DockerHub和阿里云Docker仓库 立即下载