When using Spring's dependency injection (annotations or XML) and AOP features in Spring3 or later versions, an issue was found if <aop:aspectj-autoproxy proxy-target-class= "true" is not set > always reported when fetching beans: (no beans can be obtained either by name or by type)
Org.springframework.beans.factory.NoSuchBeanDefinitionException:No Unique Bean of type
Or
Java.lang.ClassCastException:com.sun.proxy. $Proxy cannot is cast to Cn.edu.nuc.SpringTest.service.impl.DemoServiceImpl
Proxy-target-class= "True" differs from proxy-target-class= "false":
The Proxy-target-class property value determines whether an interface-based or class-based proxy is created. If the Proxy-target-class property value is set to True, then the class-based proxy will function (this requires the Cglib library). If the Proxy-target-class value is set to False or if this attribute is omitted, then the standard JDK interface-based proxy
Reference: http://forum.spring.io/forum/spring-projects/data/58033- Beannotofrequiredtypeexception-using-servicelocatorfactorybean-and-transactional
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Spring needs to set proxy-target-class= "true" when using AOP otherwise it cannot rely on injection