首页 > 其他分享 >The bean 'sysDictService' could not be injected because it is a JDK dynamic proxy

The bean 'sysDictService' could not be injected because it is a JDK dynamic proxy

时间:2022-11-09 11:44:06浏览次数:52  
标签:because daap JDK could dynamic springframework bean proxy org

问题

2022-11-09 11:26:21.693 ERROR 18228 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'sysDictService' could not be injected because it is a JDK dynamic proxy

The bean is of type 'com.sun.proxy.$Proxy134' and implements:
	org.springframework.aop.SpringProxy
	org.springframework.aop.framework.Advised
	org.springframework.cglib.proxy.Factory
	com.baomidou.mybatisplus.extension.service.IService
	org.springframework.core.DecoratingProxy

Expected a bean of type 'com.sozone.basis.dict.service.SysDictService' which 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.

解决方法 一

        // StartApplication.java 项目启动类中添加该方法
	@Bean
	@ConditionalOnMissingBean
	public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
		DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator();
		daap.setProxyTargetClass(true);
		return daap;
	}
	

解决方法 二

// application.yml
spring:
  aop:
    proxy-target-class: true

问题描述

在整理项目框架时,突然出现的问题,原先框架没有这个问题,不知道是否是动到了某个依赖造成的。。。
最后使用解决方法一,成功解决问题。解决方法二没能解决,也随手记录下,说不定后面会再遇到。

标签:because,daap,JDK,could,dynamic,springframework,bean,proxy,org
From: https://www.cnblogs.com/shanlaotou/p/16873091.html

相关文章