整数属性的验证错误(骆驼) [英] Validation error with integer property (camel)
问题描述
我在 Blueprint Camel (v 2.13.2) 中使用 OSGi 配置属性,一切都很好,直到我尝试在标签中设置一个整数属性:timePeriodMillis.
I'am using OSGi Configuration Properties in Blueprint Camel (v 2.13.2) and everything was fine until I tried to properties a integer property : timePeriodMillis in tag.
这段代码很好用:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cm:property-placeholder persistent-id="myprops"/>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<route id="rt" trace="false" autoStartup="false">
<from uri="amq://{{myQueue}}"/>
<throttle timePeriodMillis="5">
<constant>{{maxRPP}}</constant>
<to uri="direct:mock" />
</throttle>
</route>
</camelContext>
</blueprint>
当我属性 timePeriodMillis 时:
When I properties timePeriodMillis :
<throttle timePeriodMillis="{{timePM}}">
我收到两个验证错误:
cvc-attribute.3: The value '{{timePM}}' of attribute 'timePeriodMillis' on element 'throttle' is not valid with respect to its type, 'long'.
cvc-datatype-valid.1.2.1: '{{timePM}}' is not a valid value for 'integer'.
当我将其更改为(无引号)时:
When I change it to (no quote) :
<throttle timePeriodMillis={{timePM}}>
我再次收到验证错误:
Open quote is expected for attribute "timePeriodMillis" associated with an element type "throttle".
有什么想法吗?谢谢
推荐答案
请参阅 Camel 文档以了解如何使用属性占位符.[1] 中的在 XML DSL 中为任何类型的属性使用属性占位符部分解释了如何为任何类型的属性使用占位符.这允许将字符串类型 {{foo}}
用于否则需要数字的类型.
See the Camel documentation for using property placeholders. The section Using property placeholders for any kind of attribute in the XML DSL at [1] explains how to use placeholders for any kind of attribute. This allows to use string types {{foo}}
for types that otherwise would require a number.
[1] - http://camel.apache.org/using-propertyplaceholder.html
这篇关于整数属性的验证错误(骆驼)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!