嗨,我有一个 Spring Boot 应用程序,它使用 Java DSL 通过网关接口(interface)启动 Spring 集成流程。一切都可以正常运行。我添加了 AOP 来捕获异常,使用 @EnableAspectJAutoProxy(proxyTargetClass = true)
在这个阶段,它给出了错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobInitiator': Post-processing of FactoryBean's singleton object failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class com.sun.proxy.$Proxy54]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class com.sun.proxy.$Proxy54
当我删除 proxyTargetClass = true
时,它可以工作,但不会触发建议。
有什么帮助吗?有没有办法在没有网关的情况下启动 spring 集成流程?
最佳答案
没有与网关Proxy
关联的类,因此您无法建议它。
Is there a way to start the spring integration flow without a gateway?
不使用网关,而是声明 MessagingTemplate
类型的 Bean 并使用 template.sendAndReceive(someMessage)
或 template.convertSendAndReceive(somePojo)
相反。请参阅here .
(网关在内部使用 MessagingTemplate
;网关解包 MessagingException
并抛出原因,而模板则不会)。
它也不支持错误 channel 。
要更接近网关功能,您可以子类化 MessagingGatewaySupport
并调用其 sendAndReceive()
方法。
关于spring-boot - Spring Boot + Spring 集成 Java DSL + AOP : Fails to proxy the Gateway interface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34035369/