【开发笔记】java.lang.NoClassDefFoundError: org/aopalliance/intercept/MethodInterceptor

在进行“spring的声明式事务管理配置”的时候,抛出该异常。

错误原因:

缺少aopalliance.jar包。

事务管理配置如下:

    <!-- #######5.spring的声明式事务管理配置####### -->
    <!-- 5.1配置事务管理器类 -->
    <bean id="txManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"></property>
    </bean>

    <!-- 5.2配置事务增强(如何管理事务?) -->
    <tx:advice id="txAdvice" transaction-manager="txManager">
        <tx:attributes>
            <tx:method name="get*" read-only="true" />
            <tx:method name="find*" read-only="true" />
            <tx:method name="*" read-only="false" />
        </tx:attributes>
    </tx:advice>

    <!-- 5.3Aop配置:拦截哪些方法(切入点表达式)+应用上面的事务增强配置 -->
    <aop:config>
        <aop:pointcut expression="execution(* cn.itcast.a_tx.DeptService.*(..))" id="pt" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="pt"/>
    </aop:config>

由于“5.3Aop配置”那里使用了spring Aop,而之前没添加Aopjar包到项目,所以报错。

解决办法:

添加以下Aop的几个jar包到项目中

 

 

 

posted @ 2016-11-06 11:54  达哥的博客  阅读(478)  评论(0编辑  收藏  举报