当前位置: 首页 > article >正文

配置应用程序监听器[org.springframework.web.context.ContextLoaderListener]错误

首先查看自己的配置文件(我maven项目)

web.xml(内容除了文件的配置位置外,是否有其他的不同)

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">


    <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:config/springmvc-config.xml</param-value>
        </init-param>

    </servlet>

    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <!--让DispatcherServlet专注于.action-->
        <url-pattern>*.action</url-pattern>
    </servlet-mapping>

    <!--编码过滤器-->
    <filter>
        <filter-name>encoding</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>encoding</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>


    <!-- 配置加载spring文件的监听器 -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:config/application.xml</param-value>
    </context-param>

</web-app>

第二部看applicationContext配置文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-4.3.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

    <import resource="spring-mapper.xml"></import>
    <import resource="spring-service.xml"></import>
    <import resource="springmvc-config.xml"></import>


</beans>
 spring-mapper文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-4.3.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">

    <context:property-placeholder location="classpath:config/db.properties"></context:property-placeholder>
    <context:component-scan base-package="com.aqiuo.mapper"></context:component-scan>
    <!--
     dbcp:手动配置
      c3p0自动化操作
     druid
     -->

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="${jdbc.driver}"></property>
        <property name="jdbcUrl" value="${jdbc.url}"></property>
        <property name="user" value="${jdbc.username}"></property>
        <property name="password" value="${jdbc.password}"></property>
    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <!--绑定mybatis的配置文件-->
        <property name="ConfigLocation" value="classpath:config/mybatis-config.xml"></property>
    </bean>
    <!--配置DAO接口扫描包,动态的实现Dao接口可以注入Spring容器中-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.aqiuo.mapper"></property>
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
    </bean>

</beans>
spring-service文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-4.3.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
            http://www.springframework.org/schema/tx ">

    <!--扫描service包下-->
    <context:component-scan base-package="com.aqiuo.service"></context:component-scan>


    <!--配置事务管理器-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <!--配置数据源属性-->
        <property name="dataSource" ref="dataSource"></property>
    </bean>

    <!--开启事务注解支持
        当事务管理器的id是transactionManager时,可以省略指定transaction-manager属性
    -->
    <!--    <tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>-->
    <tx:annotation-driven></tx:annotation-driven>


</beans>

第三步(上面无误的话大概率是maven的问题)

如果你这部分有路径的报错,直接将这个war删除,重新引入

之后就OK了。!!!(有别的问题私我,我一直在)


http://www.kler.cn/news/161133.html

相关文章:

  • 简单实现Spring容器(一)
  • shell命令学习(1)——(待完善)
  • pycharm使用Anaconda中的虚拟环境【我的入门困惑二】
  • ros来保存图像和保存记录视频的方法---gmsl相机保存视频和图片
  • java--枚举
  • (十五)Flask覆写wsgi_app函数实现自定义中间件
  • 关于优雅的使用SQL多行转多列的记录(doris)
  • 如何使用phpStudy本地快速搭建网站并内网穿透远程访问
  • 如何使用内网穿透工具实现公网访问GeoServe Web管理界面
  • LeetCode刷题--- 计算布尔二叉树的值
  • 这些Java并发容器,你都了解吗?
  • 手写VUE后台管理系统7 - 整合Less样式
  • Inno Setup使用
  • supervisor杀死不掉程序的问题分析
  • (动手学习深度学习)第13章 实战kaggle竞赛:树叶分类
  • 4G基站BBU、RRU、核心网设备
  • VUE+THREE.JS 点击模型相机缓入查看模型相关信息
  • 云计算生成式 -给你不一样的音乐推荐新体验
  • 英伟达显卡系列与架构、代表产品
  • 基于JavaScript的jimp库处理图片,添加绘制点
  • 【华为od】存在一个m*n的二维数组,其成员取值范围为0,1。其中值为1的元素具备扩散性,每经过1S,将上下左右值为0的元素同化为1。
  • 要求CHATGPT高质量回答的艺术:提示工程技术的完整指南—第 23 章:命名实体识别提示
  • 《QDebug 2023年11月》
  • 要求CHATGPT高质量回答的艺术:提示工程技术的完整指南—第 7 章:让我们想一想 提示语
  • 背包问题学习
  • 数据结构与算法编程题50
  • NC 比telnet 强大网络命令
  • 我有才打造知识付费小程序
  • simulink trigger模块使用——多种调用案例分析
  • 出海电商中的技术护航:Socks5代理与代理IP的应用