发生错误处理XML“无法加载类[org.springframework.transaction.annotation.AnnotationTransactionAttributeSource]

问题描述:

请我需要的文件的applicationContext.xml的配置中,我使用的冬眠5.2.10和弹簧3.1.1。
我已经有这个配置,但有一个错误:发生错误处理XML“无法加载类[org.springframework.transaction.annotation.AnnotationTransactionAttributeSource]

"Error occured processing XML 'Unable to load class [org.springframework.transaction.annotation.AnnotationTransactionAttributeSource]. Are you running on Java 1.5+? Root cause: java.lang.NoSuchMethodError: org.springframework.util.ClassUtils.forName(Ljava/lang/String;)Ljava/lang/Class;'. See Error Log for more details"

<?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:aop="http://www.springframework.org/schema/aop" 
    xmlns:context="http://www.springframework.org/schema/context" 
    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/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"> 

     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> 
      <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> 
      <property name="url" value="jdbc:mysql://localhost/training"></property> 
      <property name="username" value="root"></property> 
      <property name="password" value=""></property> 
     </bean> 

     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
      <property name="dataSource" ref="dataSource"></property> 
      <property name="annotatedClasses"> 
       <list> 
        <value>co.ma.training.entity.Stagiaire</value> 
       </list> 
      </property> 
      <property name="hibernateProperties"> 
       <props> 
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> 
       </props> 
      </property> 
     </bean> 

     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 
      <property name="sessionFactory" ref="sessionFactory"></property> 
     </bean> 
     <tx:annotation-driven transaction-manager="transactionManager" /> 

     <context:annotation-config></context:annotation-config> 
     <context:component-scan base-package="co.ma.training"></context:component-scan> 

</beans> 
+0

你在混合不同版本的Spring的罐子。不要混用弹簧版本。 –

请确保在项目中使用最新的兼容的Java版本的框架。 (1.5 +)

如果你使用Maven的请尝试使用下面的属性。

<properties> 
    <maven.compiler.source>1.8</maven.compiler.source> 
    <maven.compiler.target>1.8</maven.compiler.target> 
</properties> 
+0

我使用Java版本8(Jdk8)。 –

+0

我使用项目web动态 –