然乱不能及 2021-11-28 10:21 采纳率: 100%
浏览 39
已结题

java ssm运行时出错 文件spring-config.xml、web.xml

本想ssm项目对easyui 树进行增删改的,结果. java ssm运行出错

img

控制台报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-config.xml]: Invocation of init method failed; nested exception is java.lang.BootstrapMethodError: java.lang.NoSuchMethodError: org.apache.ibatis.session.Configuration.setVfsImpl(Ljava/lang/Class;)V_

报错翻译:创建在类路径资源[spring config.xml]中定义的名为“sqlSessionFactory”的bean时出错:调用init方法失败;嵌套的异常是java.lang.BootstrapMethodError:java.lang.NoSuchMethodError:org.apache.ibatis.session.Configuration.setVfsImpl(Ljava/lang/Class;)V

spring-config图片

img

spring-config.xml文件代码:

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

    <!--加载 jdbc-->
    <context:property-placeholder
        location="classpath:jdbc.properties" ignore-unresolvable="true"/>

    <!--数据源-->
    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driver}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>

    <!--mybatis-->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!--数据源-->
        <property name="dataSource" ref="dataSource"/>
        <!--sql管理文件-->
        <property name="mapperLocations"
                  value="classpath:com/easyui/dao/*.xml"/>
        <!--数据传输模板-->
        <property name="typeAliasesPackage" value="com.easyui.pojo"/>
    </bean>

    <!--配置事务-->
    <bean id="txManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <!--定义声明式事务(面向切面)-->
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="add*"
                       isolation="REPEATABLE_READ" rollback-for="Exception"/>
            <tx:method name="update*"
                       isolation="REPEATABLE_READ" rollback-for="Exception"/>
            <tx:method name="delete*"
                       isolation="REPEATABLE_READ" rollback-for="Exception"/>
            <tx:method name="get*"
                       isolation="REPEATABLE_READ" read-only="true"/>
            <tx:method name="*"
                       isolation="REPEATABLE_READ" propagation="NOT_SUPPORTED"/>
        </tx:attributes>
    </tx:advice>

    <!--切入点-->
    <aop:config>
        <aop:pointcut
                expression="execution(* com.easyui.service..*(..))" id="point" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="point"/>
    </aop:config>

    <context:component-scan base-package="com.easyui.service">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
    </context:component-scan>

    <!--sql文件与dao接口的映射-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.easyui.dao"/>
    </bean>
</beans>



web.xml文件,一放入配置springMVC代码运行就报这个错误。

图片:

img

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <!--配置spring-->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring-config.xml</param-value>
  </context-param>
  <!--配置文件监听器-->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <!--配置springMvc-->
  <servlet>
    <servlet-name>springMVC</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>springMVC</servlet-name>
    <url-pattern>*.json</url-pattern>
  </servlet-mapping>
</web-app>

折腾了许久都没有办法解决,有什么提议我都会尝试一遍,感激不尽《加油》。

  • 写回答

1条回答 默认 最新

  • a1767028198 2021-11-28 11:19
    关注

    java.lang.NoSuchMethodError: org.apache.ibatis.session.Configuration.setVfsImpl(Ljava/lang/Class;)V_
    你这十有八九从哪找的pom.xml吧,依赖版本改改

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 12月6日
  • 已采纳回答 11月28日
  • 创建了问题 11月28日

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题