zoukankan      html  css  js  c++  java
  • SpringBoot注入Service失败

    Description:
    
    The bean 'userService' could not be injected as a 'com.phy.hemanresoruce.service.UserService' because it is a JDK dynamic proxy that implements:
    
    Action:
    
    Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.

    1.

    根据上面描述,注入userServiceImpl这个Bean时失败,(失败的原因就是实现接口,而springboot的事务默认是使用jdk的动态代理,即基于接口))。在action层中注入的Bean是实现类,因此就会报错。

    解决:将此注入Bean的方式改成了其接口


    2.

    Action:
    Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.

    再看一下idea给的建议:可以考虑下将action中注入的Bean改成接口方式或者强迫事务使用CGLib代理方式(基于类,即设置proxyTargetClass=True在启动事务管理上@EnableTransactionManagement(proxyTargetClass=True)),这种以CGLib代理方式进行,按照之前写法,应该是需要引入相应的cglib库的jar包。而在springboot中已经集成了。

  • 相关阅读:
    修改weblogic jvm启动参数
    weblogic部署步骤
    weblogic安装步骤
    sqldeveloper 导出数据库
    VO与PO 的理解
    【Hyper-V】与【VirtualBox】【VMware】冲突的解决方法
    xstream 实现simplebean2xml ,xml2simplebean
    eclipse中SVN报错解决
    点击eclipse包报错
    myeclipce项目导入eclipse中报错
  • 原文地址:https://www.cnblogs.com/phyqxx/p/11572239.html
Copyright © 2011-2022 走看看