使用Reactor 2的My Spring 4应用程序无法启动:
***************************
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.
OrderHandlerConsumer
非常简单:
@Service
@Order(Ordered.HIGHEST_PRECEDENCE)
public class OrderHandlerConsumer implements Consumer<Event<OrderEnvelope>> {
@Override
public void accept(Event<OrderEnvelope> event) {
event.getData().getLatch().countDown();
}
}
任何想法可能会出错?
答案 0 :(得分:1)
在将其定义为Spring应用程序的应用程序类文件中,在其下面添加。
@SpringBootApplication
@EnableCaching(proxyTargetClass = true)
答案 1 :(得分:1)
请尝试如下自动接线
class Test{
@Autowired
private Consumer orderHandlerConsumer;
}
答案 2 :(得分:0)
您可以为您的OrderHandlerConsumer类分配一个bean名称,这样可以更轻松地实现自动装配解析。此外,与其尝试使用具体的类自动装配,还不如尝试使用该接口自动装配。这样您就可以将@Service批注更改为
@Service(value="orderHandlerConsumer")
并尝试使用接口类型
自动接线@Autowire
reactor.fn.Consumer orderHandlerConsumer;