Apache camel ApacheCamel-在SpringXML中读取java常量
正在尝试读取SpringXML文件中的java常量 在spring.xml文件中Apache camel ApacheCamel-在SpringXML中读取java常量,apache-camel,Apache Camel,正在尝试读取SpringXML文件中的java常量 在spring.xml文件中 <util:constant id="speed" static-field="<packageName>.<constantclassname>.<constantName>" /> 并使用属性占位符读取它 <bean id="bridgePropertyPlaceHolder" class="org.apache.camel.spring.s
<util:constant id="speed"
static-field="<packageName>.<constantclassname>.<constantName>" />
并使用属性占位符读取它
<bean id="bridgePropertyPlaceHolder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="properties">
<props>
<prop key="testProperty">#{speed}</prop>
</props>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
#{speed}
以及在打印属性的过程中
<route>
<from uri=""/>
<setProperty propertyname="test">
<simple>{{testProperty}}</simple>
</setProperty>
<log message="print ${property[test]"/>
</route>
{{testProperty}}
并且在常量java类文件中定义了如下常量
public static final String <constantName> ="xxxx";
public static final String=“xxxx”;
在运行这个时,我得到了
线程“main”org.apache.camel.runtimecameleexception:javax.xml.bind.jaxbeexception:Provider com.sun.xml.bind.v2.ContextFactory无法实例化:javax.xml.bind.jaxbeexception:“xxxx”不包含ObjectFactory.class或jaxb.index
-除此之外:
[javax.xml.bind.JAXBException:“xxxx”不包含ObjectFactory.class或jaxb.index]
我不确定为什么需要ObjectFactory.class
请帮助我解决这个问题,或者是否有其他方法读取spring.xml中的java常量文件
请建议
谢谢。这是从类中直接读取Java常量的另一种方法。 您可以使用camel简单语言
<route>
<from uri=""/>
<setProperty propertyname="test">
<simple>${type:<packageName>.<constantclassname>.<constantName>}</simple>
</setProperty>
<log message="print ${property[test]"/>
</route>
${type:..}