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中已经集成了。

SpringBoot注入Service失败的更多相关文章

  1. SpringBoot注入Mapper失败

    SpringBoot注入Mapper失败,可能是因为没有加扫描Mapper层的注解 方式一:在所有mapper接口使用@Mapper注解 @Mapper public interface UserMa ...

  2. Spring注解问题,[action中注入service失败

    pring-mvc.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns=" ...

  3. springboot拦截器注入service为空

    一般都是因为除了在拦截器之外,还需要在拦截器的配置类中,注册拦截器时没有使用spring的bean,而是使用了new创建bean造成的. @Configuration public class Web ...

  4. 新人踩坑的一天——springboot注入mapper时出现java.lang.NullPointerException: null

    来公司的第二周接到了定时任务的开发需求:每天早上十点发送用户报表邮件 .校招新人菜鸟没做过这玩意有些懵(尴尬)于是决定分步写,从excel导出->邮件发送->定时器实现->mappe ...

  5. 如何在Java Filter 中注入 Service

    在项目中遇到一个问题,在 Filter中注入 Serivce失败,注入的service始终为null.如下所示: public class WeiXinFilter implements Filter ...

  6. spring整合Jersey 无法注入service的问题

    现象: action中的@autowired注入service或dao失败,报空指针异常 原因: 造成该问题的原因是你并没有做好spring和jersey的整合工作,检查你的web.xml文件,jer ...

  7. 如何在Java的Filter中注入Service???

    今天在做用户使用cookie自动登录的时候,发现在LoginFilter中读取到cookie以后要进行查询数据库然后进行用户名和密码的比对,查询数据库肯定要用到Service和Dao,一开始我以为在s ...

  8. Myeclipse插件快速生成ssh项目并配置注解 在action层注入service的超详细过程

    最近发现,我对于ssh的 自动注入配置 还是不熟悉,于是整理了一下 终于做了一个 简单的 注入配置出来. 以前都是在applicationContext.xml 里面这样配 <bean id=& ...

  9. 关于如何在Listener中注入service和ServletContextListener源码分析

      今天在做项目时突然发现我该如何向listener中注入service对象,因为监听器无法使用注解注入. 此时有人会想用以下代码通过xml的方式注入: ApplicationContext cont ...

随机推荐

  1. atcoder E - Jigsaw(思维)

    题目链接:http://agc017.contest.atcoder.jp/tasks/agc017_e 题解:这题很巧妙运用了cnt[i]抽象的表示了上下互补的状态,最后上面突出的一定要处理完.下面 ...

  2. lightoj 1032 - Fast Bit Calculations(数位dp)

    A bit is a binary digit, taking a logical value of either 1 or 0 (also referred to as "true&quo ...

  3. 自定义Hive UDAF 实现相邻去重

    内置的两个聚合函数(UDAF) collect_list():多行字符串拼接为一行collect_set():多行字符串拼接为一行并去重多行字符串拼接为一行并相邻去重UDAF:Concat() con ...

  4. 设置普通用户输入sudo,免密进入root账户

    满足给开发用户开权限,赋予sudo权限.又不让其输入密码的方式: 方式一: 开始系统内部的wheel用户组, 在/etc/suoers 中编辑配置文件如下: %wheel ALL=(ALL) NOPA ...

  5. MariaDB数据库自学一

    在CentOS下安装Mariadb 数据库,命令: yum -y mariadb mariadb.server 等待几分钟后就可以自动完成安装了,然后启动对应的服务: systemctl  start ...

  6. 阿里社招Java面试题总结——面试官分享

    面试题 1.Java中的内存溢出是如何造成的 2.gc的概念,如果A和B对象循环引用,是否可以被GC? 3.Error.Exception和RuntimeException的区别,作用又是什么? 4. ...

  7. spring中的XML Catalog配置

    XML Catalog配置: 1.window-->preferences-->XML Catalog 2.如图: 点击File System,选择下图中的最后一个 图二中的key时sch ...

  8. asp.net core 使用 signalR(一)

    asp.net core 使用 signalR(一) Intro SignalR 是什么? ASP.NET Core SignalR 是一个开源代码库,它简化了向应用添加实时 Web 功能的过程. 实 ...

  9. webview与webApp页面交互传参

    参考网址:https://blog.csdn.net/books1958/article/details/44747045 上一篇说了Android集成极光推送获取了RegistrationId推送标 ...

  10. ExpandableListView 可折叠的下拉listview

    ExpandableListView用法如下 1.定义布局文件main.xml文件 <?xml version="1.0" encoding="utf-8" ...