我使用带模块的d簧靴.我有一个包含多个子模块的父项目.
当我使用Contructor autowiring配置路由时,Camel Routes无法启动.
我得到Total 0路由,其中0是启动时启动这样的构造函数.
private final ScanProcessor scanProcessor;private final ScheduleProcessor scheduleProcessor;private final TagProcessor tagProcessor;private final LatestScanProcessor latestScanProcessor;private final RabbitMqService rabbitMqService;@autowiredpublic DashboardRoute(ScanProcessor scanProcessor,ScheduleProcessor scheduleProcessor,TagProcessor tagProcessor,LatestScanProcessor latestScanProcessor,RabbitMqService rabbitMqService){ this.scanProcessor = scanProcessor; this.scheduleProcessor = scheduleProcessor; this.tagProcessor = tagProcessor; this.latestScanProcessor = latestScanProcessor; this.rabbitMqService = rabbitMqService;}@OverrIDepublic voID configure() throws Exception { from(CONSUME_SCHEDulE_ROUTE) .routeID("consume-schedule") .process(scheduleProcessor); // no strings}
当我不对任何豆子进行自动装配并对这样的路线进行处理时,整个过程都有效.
from(CONSUME_SCHEDulE_ROUTE) .routeID("consume-schedule") .process("scheduleProcessor") // notice this is a string
骆驼是否支持d簧路径Contructor自动装配?我是否需要采取一些额外的配置步骤才能正确处理?我更喜欢直接链接bean,当我重构它连接回来的类名时ok.最佳答案我尝试了与你相似的例子,它工作正常.您可以确保在路由类和所有处理器类和服务类中都有@Compoent.
您也可以尝试在局部变量上添加@autowired. (构造函数应该可以正常工作.这只是确保构造函数工作的额外工具)
@Component@ServletComponentScan(basePackages = "com.example.camel")public class ServiceRoutes extends RouteBuilder { @autowired private ScanProcessor scanProcessor; @autowired private ScheduleProcessor scheduleProcessor; @autowired private TagProcessor tagProcessor; @autowired private LatestScanProcessor latestScanProcessor; @autowired private RabbitMqService rabbitMqService; @OverrIDe public voID configure() throws Exception { from(CONSUME_SCHEDulE_ROUTE) .routeID("consume-schedule") .process(scheduleProcessor); }}
希望这可以帮助. 总结
以上是内存溢出为你收集整理的java – 自动装配构造函数时没有路径的Camel全部内容,希望文章能够帮你解决java – 自动装配构造函数时没有路径的Camel所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)