Shane Gannon
Shane Gannon

Reputation: 7738

How to enabled CGLIB proxies on @Component?

I'm seeing an error in my SpringBoot Application after using the micrometer @Timed annotation.

Bean named 'XXXX' is expected to be of type 'xxxx.XXXX' but was actually of type 'com.sun.proxy.$Proxy223'

This is novel to me, but I'm now aware of the difference between JDK and CGLIB proxies.

In terms of a soluton the first option is to use an Interface. But, as I'm timing private methods, I'm hesitant to take this approach. That means CGLIB proxies or switching away from @Timed and toward registry.timer(...).

I've come across EnableAspectJAutoProxy but it's usage is not clear to me for a @Component. Should it just work once it's set on my @Configuration or @SpringBootApplication classes? Neither of which have worked.

Upvotes: 1

Views: 287

Answers (0)

Related Questions