当你按如下方式配置bean时:
@Bean@StepScopepublic MyInterface myBean() { return new MyInterfaceImpl();}
你正在告诉Spring使用代理模式
ScopedProxyMode.TARGET_CLASS。但是,通过返回
MyInterface而不是返回,
MyInterfaceImpl代理仅具有对上方法的可见性
MyInterface。这将阻止
Spring Batch能够在
MyInterfaceImpl已使用侦听器注释(例如)进行注释的方法上找到方法@BeforeStep。正确
MyInterfaceImpl的配置方法是返回你的配置方法,如下所示:
@Bean@StepScopepublic MyInterfaceImpl myBean() { return new MyInterfaceImpl();}
我们在启动时添加了一条警告日志消息,该消息指出,当我们寻找带注释的侦听器方法时,如果该对象被代理并且目标是接口,则将无法在实现类上找到带有注释的方法他们。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)