在Spring的配置事务的过程中,出现如下错误, Configuration problem: Cannot locate BeanDefinitionDecorator for element [advice]请大家给帮帮忙,自己不知道是为什么?
出问题的Spring配置文件如下: 
<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:tx="http://www.springframework.org/schema/tx"                                     
xsi:schemaLocation="
http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd" >


<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>


<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>


<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>

<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>


<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* edu.ysu.usermgr.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
</aop:config>

</bean>
</beans>

解决方案 »

  1.   

    通过XML元素来查找BeanDefinitionDecorator,你的错误是找不到那个BeanDefinitionDecorator.好好看下配置文件,是不是前缀和引用出可错误.
      

  2.   

    <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:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <!-- 事务处理 -->
    <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
    </bean> <!-- 事务控制 -->
    <tx:advice id="txAdvice"
    transaction-manager="transactionManager">
    <tx:attributes>
    <tx:method name="save*" propagation="REQUIRED" />
    <tx:method name="update*" propagation="REQUIRED" />
    <tx:method name="remove*" propagation="REQUIRED" />
    <tx:method name="get*" read-only="true" />
    </tx:attributes>
    </tx:advice> <aop:config>
    <!-- 管理事务操作 -->
    <aop:pointcut id="servicesPointcut"
    expression="execution(* com.jack.user.model.*.*(..))" />
    <aop:advisor advice-ref="txAdvice"
    pointcut-ref="servicesPointcut" />
    </aop:config>
    和上面的内容比较下,看看不是不那里有缺少啦.