admin管理员组文章数量:1026989
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.
问题描述
Spring Boot 项目,启用事务支持时出现以下错误:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled.
2018-12-28 09:19:09.467 ERROR 1105 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
The bean ‘departmentDao’ could not be injected as a ‘com.wanyu.fams.dao.DepartmentDao’ 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.
也就是添加了一个注解:@Transactional // 启用事务处理,启动的时候就报错了。
解决方法
在 application.properties 或者 application.yml 配置文件中添加配置:
以下为 application.properties 中的配置方法:
解决问题
spring.aop.proxy-target-class=true
application.yml 写法有点不同:
spring:
aop:
proxy-target-class: true
失败的尝试
有文章指出:在springboot启动类中添加如下代码,最终解决问题,我尝试失败,错误依旧!
@Bean
@ConditionalOnMissingBean
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator();
daap.setProxyTargetClass(true);
return daap;
}
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.
问题描述
Spring Boot 项目,启用事务支持时出现以下错误:
Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled.
2018-12-28 09:19:09.467 ERROR 1105 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :
APPLICATION FAILED TO START
Description:
The bean ‘departmentDao’ could not be injected as a ‘com.wanyu.fams.dao.DepartmentDao’ 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.
也就是添加了一个注解:@Transactional // 启用事务处理,启动的时候就报错了。
解决方法
在 application.properties 或者 application.yml 配置文件中添加配置:
以下为 application.properties 中的配置方法:
解决问题
spring.aop.proxy-target-class=true
application.yml 写法有点不同:
spring:
aop:
proxy-target-class: true
失败的尝试
有文章指出:在springboot启动类中添加如下代码,最终解决问题,我尝试失败,错误依旧!
@Bean
@ConditionalOnMissingBean
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator();
daap.setProxyTargetClass(true);
return daap;
}
本文标签: interfacesBeaninjectingforcingproxies
版权声明:本文标题:Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies 问题解决 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1738334411a1562420.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论