英文:
camel <to uri> sending string
问题
I would like to send string which presents column name and after there is sql to get data then send all on csv.
我的目标是在CSV上有列标题。
I know that there is camel csv option to output column header but any of option worked for me so i try to send string before the data written on CSV.
我知道有骆驼CSV选项可以输出列标题,但其中任何选项都对我不起作用,所以我尝试在将数据写入CSV之前发送字符串。
I would like to know if i can send String to camel csv ? if yes, could you please advise me how ?
我想知道是否可以将字符串发送到骆驼CSV?如果可以,你能告诉我如何做吗?
XML
<to uri="bean:testImpl?method=columnHeader()" />
<to uri="sql:{{order.query}}?dataSource=orderDataSource" />
<marshal>
<csv delimiter=";" />
</marshal>
Java testImpl.class
public String columnHeader() {
return "header1;header2;header3;header4;header5;header6;header7";
}
I tried like this but the program doesn't recognize the method columnHeader in testImpl.class
error: org.apache.camel.component.bean.MethodNotFoundException: Method with name: columnHeader() not found on bean
Thank you for your help.感谢你的帮助。
英文:
I would like to send string which presents column name and after there is sql to get data then send all on csv.
My goal is to have column header on csv.
I know that there is camel csv option to output column header but any of option worked for me so i try to send string before the data written on CSV.
I would like to know if i can send String to camel csv ? if yes, could you please advise me how ?
XML
<to uri="bean:testImpl?method=columnHeader()" />
<to uri="sql:{{order.query}}?dataSource=orderDataSource" />
<marshal>
<csv delimiter=";" />
</marshal>
Java testImpl.class
public String columnHeader() {
return "header1;header2;header3;header4;header5;header6;header7";
}
I tried like this but the programe doesn't recognize the method columnHeader in testImpl.class
error : org.apache.camel.component.bean.MethodNotFoundException: Method with name: columnHeader() not found on bean
Thank you for you help
答案1
得分: 0
你的Java类真的是一个Camel(或Spring)Bean吗?对于在Camel路由中使用Bean,它们必须在上下文中注册为Bean。
在Spring中,可以通过@Component
注解或通过Java或XML配置Bean来实现这一点。
英文:
Is your Java class really a Camel (or Spring) Bean? For the use of Beans in a Camel Route, they must be registered Beans in the Context.
In Spring this can be achieved with the @Component
annotation or by configuring the Bean with Java or XML.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论