My Spring 4 application, which uses Reactor 2, fails to start with:
*************************** APPLICATION FAILED TO START *************************** Description: The bean 'orderHandlerConsumer' could not be injected as a 'fm.data.repository.OrderHandlerConsumer' because it is a JDK dynamic proxy that implements: reactor.fn.Consumer 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.
The OrderHandlerConsumer
is really simple:
@Service @Order(Ordered.HIGHEST_PRECEDENCE) public class OrderHandlerConsumer implements Consumer<Event<OrderEnvelope>> { @Override public void accept(Event<OrderEnvelope> event) { event.getData().getLatch().countDown(); } }
Any ideas what might be going awry?
JDK Dynamic Proxies allow one to create implementations of Java interfaces at runtime by the means of Reflection. A proxy may be seen as a subject that will forward method calls to target instances and eventually return any result produced by the target instance to the caller.
Spring AOP uses either JDK dynamic proxies or CGLIB to create the proxy for a given target object. (JDK dynamic proxies are preferred whenever you have a choice). If the target object to be proxied implements at least one interface then a JDK dynamic proxy will be used.
JDK dynamic proxy is available with the JDK. It can be only proxy by interface so target class needs to implement interface. In your is implementing one or more interface then spring will automatically use JDK dynamic proxies. On the other hand, CGLIB is a third party library which spring used for creating proxy.
In your application class file where you define it as Spring application, add underneath it.
@SpringBootApplication @EnableCaching(proxyTargetClass = true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With