我在模块中使用 spring boot。我有一个包含多个子模块的父项目。
当我使用 Contructor Autowiring 配置路由时,Camel 路由无法启动。
我得到 Total 0 routes, 其中 0 已启动当像这样启动构造函数时。
private final ScanProcessor scanProcessor;
private final ScheduleProcessor scheduleProcessor;
private final TagProcessor tagProcessor;
private final LatestScanProcessor latestScanProcessor;
private final RabbitMqService rabbitMqService;
@Autowired
public 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;
}
@Override
public void configure() throws Exception {
from(CONSUME_SCHEDULE_ROUTE)
.routeId("consume-schedule")
.process(scheduleProcessor); // no strings
}
当我不 Autowiring 任何 bean 并像这样删除路由时,整个事情就有效了。
from(CONSUME_SCHEDULE_ROUTE)
.routeId("consume-schedule")
.process("scheduleProcessor") // notice this is a string
camel 是否支持 spring route Constructor Autowiring ?我是否需要采取一些额外的配置步骤来正确处理这个问题?当我重构类名时,我更喜欢以这种方式直接链接 bean,它可以正常链接回来。
最佳答案
我尝试了与您类似的示例并且它工作正常。您可以确保在路由类以及所有处理器类和服务类中都有@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 - Autowiring 构造函数时 Camel 没有路线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49753768/
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我正在尝试用ruby中的gsub函数替换字符串中的某些单词,但有时效果很好,在某些情况下会出现此错误?这种格式有什么问题吗NoMethodError(undefinedmethod`gsub!'fornil:NilClass):模型.rbclassTest"replacethisID1",WAY=>"replacethisID2andID3",DELTA=>"replacethisID4"}end另一个模型.rbclassCheck 最佳答案 啊,我找到了!gsub!是一个非常奇怪的方法。首先,它替换了字符串,所以它实际上修改了
我有一些代码在几个不同的位置之一运行:作为具有调试输出的命令行工具,作为不接受任何输出的更大程序的一部分,以及在Rails环境中。有时我需要根据代码的位置对代码进行细微的更改,我意识到以下样式似乎可行:print"Testingnestedfunctionsdefined\n"CLI=trueifCLIdeftest_printprint"CommandLineVersion\n"endelsedeftest_printprint"ReleaseVersion\n"endendtest_print()这导致:TestingnestedfunctionsdefinedCommandLin
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
大家好!我想知道Ruby中未使用语法ClassName.method_name调用的方法是如何工作的。我头脑中的一些是puts、print、gets、chomp。可以在不使用点运算符的情况下调用这些方法。为什么是这样?他们来自哪里?我怎样才能看到这些方法的完整列表? 最佳答案 Kernel中的所有方法都可用于Object类的所有对象或从Object派生的任何类。您可以使用Kernel.instance_methods列出它们。 关于没有类的Ruby方法?,我们在StackOverflow
我真的为这个而疯狂。我一直在搜索答案并尝试我找到的所有内容,包括相关问题和stackoverflow上的答案,但仍然无法正常工作。我正在使用嵌套资源,但无法使表单正常工作。我总是遇到错误,例如没有路线匹配[PUT]"/galleries/1/photos"表格在这里:/galleries/1/photos/1/edit路线.rbresources:galleriesdoresources:photosendresources:galleriesresources:photos照片Controller.rbdefnew@gallery=Gallery.find(params[:galle
我在Rails应用程序中使用CarrierWave/Fog将视频上传到AmazonS3。有没有办法判断上传的进度,让我可以显示上传进度如何? 最佳答案 CarrierWave和Fog本身没有这种功能;你需要一个前端uploader来显示进度。当我不得不解决这个问题时,我使用了jQueryfileupload因为我的堆栈中已经有jQuery。甚至还有apostonCarrierWaveintegration因此您只需按照那里的说明操作即可获得适用于您的应用的进度条。 关于ruby-on-r