问题
I'm trying to configure a custom PropertiesComponent for my CamelContexts via Spring. According to this page, I simply need to add a bean definition of type org.apache.camel.component.properties.PropertiesComponent
. However, my CamelContext isn't picking it and I can't seem to find a way to reference the bean from within the CamelContext. I just keep getting the following error:
PropertiesComponent with name properties must be defined in CamelContext to support property placeholders.
How can add a PropertiesComponent to the context via Spring? (I do not want to use the propertyPlaceholder
tag.)
What I have so far. (I'll subclass PropertiesComponent as soon as I can get this working.)
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
<property name="location" value="classpath:props.properties" />
</bean>
<camelContext xmlns="http://camel.apache.org/schema/spring" id="eventService">
<routeBuilder ref="httpInbound" />
</camelContext>
回答1:
When you define the properties
object inside the spring application context, camel will look up the PropertiesComponent from the Spring application context by using that name.
回答2:
Perhaps you are experiencing this camel regression - if so, you can upgrade to 2.11.1 in which it is fixed.
回答3:
Did you try defining property placeholder inside camel context?
<camelContext xmlns="http://camel.apache.org/schema/spring" id="eventService">
<propertyPlaceholder id="properties" location="classpath:props.properties"/>
<routeBuilder ref="httpInbound" />
</camelContext>
来源:https://stackoverflow.com/questions/17731225/camel-custom-propertiescomponent