Spring AOP - how do I make a proxied bean?

I configured Spring -AOP to bean.

When I access this bean, it returns me the spring proxy class instead of the actual bean.

Is there any way to get the actual bean?

applicationContext.xml

<bean id="abc" class="abc.java" />

some.java

abc a = (abc)applicationContext.getBean("abc")

this throws out:

java.lang.ClassCastException: $Proxy19

+3
source share
2 answers

You will need to send it to the Proxy Object for starters. Then try:

Proxy.getTargetSource().getTarget

I really don't know if this will work, the AOP documentation is very ambiguous when describing return types for Proxy classes, it says "Returns

+3
source

bean, Spring -, bean (suing CGLIB), -, bean .

bean , . . , . , bean, ?

Spring AOP , bean, proxy-target-class. , AOP, .

+2

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


All Articles