问题描述
我正在添加新的骆驼路由xml。我无法获取到URI的日期值。 <?xml version =1.0encoding =UTF- 8standalone =yes?>
< route xmlns =http://www.myCompany.com/123/api/route/1.0>
//...some lines
....
< from>
< uri> ...< / uri>
....
.....
< / from>
< to>
< uri> file:// C:/ mywork / $ {date:now:yyyy} - $ {date:now:MM} - $ {date:now:dd}< / uri>
< / to>
< / route>
当我使用这个以上获取CaughtExceptionType:groovy.lang.MissingPropertyException,CaughtExceptionMessage:没有这样的属性: yyyy for class:script1465913927580309309860,StackTrace:groovy.lang.MissingPropertyException:没有这样的属性:yyyy类:script1465913927580309309860
在URI中我已经提到了yyyy- MM-dd格式。我不知道如何在那里得到日期。简而言之,我想要uri为'C:/ myWork / 2011-01-01'。我想的是这个问题是因为groovy解析'uri'值
感谢提前。
尝试将日期格式更改为:$ {date:now:yyyy-MM-dd}此格式可以让您在单次更换期间表达所需的日期。
所以你端点应如下所示:
< to>
< uri> file:// C:/ mywork / $ {date:now:yyyy-MM-dd}< / uri>
< / to>
I am adding new camel route xml. I am having trouble getting date value in to to URI.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<route xmlns="http://www.myCompany.com/123/api/route/1.0">
//...some lines
....
<from>
<uri>...</uri>
....
.....
</from>
<to>
<uri>file://C:/mywork/${date:now:yyyy}-${date:now:MM}-${date:now:dd}</uri>
</to>
</route>
When I use this as above getting CaughtExceptionType: groovy.lang.MissingPropertyException, CaughtExceptionMessage: No such property: yyyy for class: script1465913927580309309860, StackTrace: groovy.lang.MissingPropertyException: No such property: yyyy for class: script1465913927580309309860
In to URI I have mentioned the folder name with yyyy-MM-dd format.I do not know how to get date there. In short I want to uri as 'C:/myWork/2011-01-01'. THe problem I am thinking of is because of groovy parsing the 'to uri' valueThanks in advance.
Try changing your date format to: ${date:now:yyyy-MM-dd} This format will let you express the desired date in a single replacement.
So your endpoint should look like:
<to>
<uri>file://C:/mywork/${date:now:yyyy-MM-dd}</uri>
</to>
这篇关于如何动态添加日期到骆驼路由xml'到uri'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!