Spring Problem with ProxyFactoryBean Injection

I have a ProxyFactoryBean bean:

<bean id="sendSingleSmsServiceProxy" class="org.springframework.aop.framework.ProxyFactoryBean">
   <property name="target">
      <ref bean="sendSingleSmsServiceImpl" />
   </property>
   <property name="proxyInterfaces">
      <value>com.test.SendSingleSmsService</value>
   </property>
   <property name="interceptorNames">
      <value>hibernateInterceptor</value>
   </property>
</bean>

and I'm trying to inject this bean into another using the @Resource annotation, here is my code for this:

@Resource
public ProxyFactoryBean sendSingleSmsServiceProxy;

but I get this exception:

org.springframework.beans.factory.BeanCreationException: an error occurred while creating a bean named 'com.test.webservice.impl.SendSingleSmsImpl': resource injection could not be started; The nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: the bean named 'sendSingleSmsServiceProxy' must be of type [org.springframework.aop.framework.ProxyFactoryBean], but it is actually of type [$ Proxy24]

Any help would be appreciated.

+3
source share
1

, ProxyFactoryBean. FactoryBean, bean FactoryBean, bean factory (. Spring docs)

sendSingleSmsServiceProxy bean SendSingleSmsService:

@Resource
public SendSingleSmsService sendSingleSmsService;

ProxyFactoryBean , , , , .

+5

Source: https://habr.com/ru/post/1776855/


All Articles