错误提示: 1:java.lang.IllegalStateException: Failed to load ApplicationContext

    2:Error creating bean with name 'userService' defined in class path resource [UserService.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.

    3:Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.

根本原因:由于web在加载spring的配置文件(applicationContext.xml)时,发生了错误,而错误是3(cglib2不可用),所以根本原因是缺少cglib的包。

applicationContext.xml中的代理配置如下

  <!-- 指定使用cglib -->
    <aop:aspectj-autoproxy proxy-target-class="true" />
    
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="*" />
        </tx:attributes>
    </tx:advice>
    <!-- 通过AOP配置提供事务增强,让service包下所有bean的所有方法拥有事务 -->
    <aop:config proxy-target-class="true">
        <aop:pointcut id="serviceMethod" expression=" execution(* com.luxl.service..*(..))" />
        <aop:advisor pointcut-ref="serviceMethod" advice-ref="txAdvice" />
    </aop:config>

解决方法:在maven中添加cglib的包,如下:

  <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
    </dependency>

最新文章

  1. RAID磁盘阵列笔记
  2. java生成带logo的二维码,自定义大小,logo路径取服务器端
  3. Oracle 数据库基础学习 (三) Oracle 四个表结构
  4. Weblogic监控指标
  5. shinydashboard包---为shiny提供BI框架
  6. kali linux安装virtualbox虚拟机之爬坑经历
  7. Windows 8.1 应用再出发 - 创建我的第一个应用
  8. 解决centos7重启后出现ata bus error
  9. matlab学习笔记 bsxfun函数
  10. suibi11172
  11. IIS 7.5站点配置
  12. validate中remote的用法
  13. MYSQL----myownstars(102)
  14. Atitit.hibernate体系结构大总结
  15. json数据相对于xml数据.
  16. final关键字的作用
  17. 性能测试工具:AB
  18. Bootstrap入门(二十五)JS插件2:过渡效果
  19. SQL Server 安装报错找不到vc_red.msi
  20. Android 7.1 屏幕旋转流程分析

热门文章

  1. 底层并发APIs_源自objc.io
  2. 从零开始徒手撸一个vue的toast弹窗组件
  3. 解决VMware安装Ubuntu的过程中窗口过小无法看到【下一步】按钮的问题
  4. c#-关于自动属性的思考
  5. Python机器视觉编程常用数据结构与示例
  6. Dijkstra再理解+最短路计数
  7. 高并发服务器架构--SEDA架构分析
  8. 【旧文章搬运】Windows句柄分配算法(二)
  9. k8s-调度器、预选策略及优选函数-二十
  10. html5盒子模型