You need to use BridgePropertyPlaceholderConfigurer[1] to let Spring and Camel knows about the properties file.
[1]http://camel.apache.org/properties.html#Properties-BridgingSpringandCamelpropertyplaceholders -- Willem Jiang Red Hat, Inc. Web: http://www.redhat.com Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English) http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese) Twitter: willemjiang Weibo: 姜宁willem On Saturday, November 16, 2013 at 9:45 PM, Joao Vicente wrote: > I am having some trouble getting a data source setup using Camel properties > component. > So, I have a db.properties that contains configuration for my datasource > (showing only url for brevity) > My route builder seems to be able to resolve the property, but the data > source does not seem to do so. > The evidence for this is shown in the console output below. > I wonder could anyone shed some light to why this could be happening? > > > db.properties > datasource.stg.url=jdbc:oracle:thin:... > > camel-context.xml > ... > <bean id="properties" > class="org.apache.camel.component.properties.PropertiesComponent"> > <property name="location" value="classpath:db.properties"/> > </bean> > > <bean id="auditDataSourceStg" > class="org.apache.commons.dbcp.BasicDataSource"> > <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> > <property name="url" value="{{datasource.stg.url}}"/> > <property name="username" value="{{datasource.stg.username}}"/> > <property name="password" value="{{datasource.stg.password}}"/> > <property name="initialSize" value="5" /> > <property name="maxActive" value="10" /> > </bean> > ... > > MyRouteBuilder.java > ... > public void configure() { > from(fromQueryBuilder) > .log("[queryyBuilder] url:{{datasource.stg.url}}") > > Console output > 2013-11-16 13:20:15,609 [queryBuilder] INFO route1 > - [queryBuilder] url:jdbc:oracle:thin:... > Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' for > connect URL '{{datasource.stg.url}}' > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Camel-properties-component-not-being-resolved-when-configuring-data-source-tp5743375.html > Sent from the Camel - Users mailing list archive at Nabble.com > (http://Nabble.com).
