项目配置完,启动tomcat报错。Context initialization failed。

来源:5-4 添加事务管理-Spring整合Hibernate

慕移动2735134

2018-08-21 16:03

 [DEBUG] 2018-08-21 15:54:33,179 Found XML schema [http://www.springframework.org/schema/tx/spring-tx.xsd] in classpath: org/springframework/transaction/config/spring-tx-3.2.xsd
 [DEBUG] 2018-08-21 15:54:33,198 Loading bean definitions
 [DEBUG] 2018-08-21 15:54:33,234 Loaded NamespaceHandler mappings: {...}
 [ERROR] 2018-08-21 15:54:33,374 Context initialization failed
  org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [applicationContext.xml]; 
  nested exception is java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
  at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
  at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
  ......

jdk版本1.7,spring版本3.2

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

    <!-- 引入外部属性文件 -->
    <context:property-placeholder location="classpath:jdbc.properties" />
    <!-- 配置连接池c3p0 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
       <property name="jdbcDriver" value="${jdbc.driver}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="jdbcUsername" value="${jdbc.username}" />
        <property name="jdbcPassword" value="${jdbc.password}" />
    </bean>

    <!-- 配置hibernate相关属性 -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <!-- 注入连接池 -->
        <property name="dataSource" ref="dataSource"></property>
        <!-- 配置hibernate属性 -->
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>

        <!-- 加载hibernate映射文件 -->
        <property name="mappingResource">
            <list>
                <value>com/lmx/employee/domain/Department.hbm.xml</value>
                <value>com/lmx/employee/domain/Employee.hbm.xml</value>
            </list>

        </property>

    </bean>
    <!-- 配置action -->
    <!-- 配置service -->
    <!-- 配置dao -->
    <!-- 配置事务管理器 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <!-- 注入sessionFactory -->
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    <!-- 开启注解事务 -->
    <tx:annotation-driven transaction-manager="transactionManager" />

</beans>

看了好多博客的讲解和解决方法,最后还是没看懂,也没解决。如上问题怎么解决?


写回答 关注

1回答

  • 慕移动2735134
    2018-08-21 16:25:49
    java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor

    此问题以解决缺少aopalliance-1.0.jar

    下载地址https://pan.baidu.com/s/1sjHOLIl


基于SSH实现员工管理系统之框架整合篇

本视频教程主要介绍环境搭建和SSH框架整合,逐层深入理解学习

49831 学习 · 344 问题

查看课程

相似问题