Results 1 to 5 of 5

Thread: p: property with data coming from a .properties file

  1. #1
    Join Date
    Jan 2008
    Posts
    10

    Default p: property with data coming from a .properties file

    Hi,

    I would like to combine the power of p:someData with value comming from a property file.

    Somethink similar to:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    	   xmlns="http://www.springframework.org/schema/beans"
    	   xmlns:p="http://www.springframework.org/schema/p" 
    	   xmlns:util="http://www.springframework.org/schema/util"
    	   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    						   http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
    	<util:properties id="properties" location="classpath:META-INF/config/datasource.properties" />
    	<!-- JDBC DataSource -->
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
        p:driverClassName="${datasource.driverClassName}"
    		p:url="${datasource.url}" 
    		p:username="${datasource.username}" 
    		p:password="${datasource.password}">
    	</bean>
    	<!-- JNDI DataSource -->
    	<!--
    		<jee:jndi-lookup id="datasources.samples" jndi-name="${datasource.jndi.name}">
    		<jee:environment>target=${properties.dataSource.jndi.target}</jee:environment> </jee:jndi-lookup>
    	-->
    </beans>
    Thanks.

  2. #2
    Join Date
    Jan 2008
    Posts
    10

    Question

    Is it not possible or nobody knows?

    Thanks.

  3. #3
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    Perhaps you should try asking a specific question?

  4. #4
    Join Date
    Jan 2008
    Posts
    10

    Default

    Well,

    The question whas "how to do this" ?

    It looks that p:blabla is not accepting value passed from the property file.

    Did I make a mistake or is it not supported ?

    Thanks for help.

  5. #5
    Join Date
    Jan 2008
    Posts
    10

    Default I finally found what was going wrong here !

    Code:
    	<context:property-placeholder properties-ref="properties"/>
    
    	<util:properties id="properties" location="classpath:META-INF/config/datasource.properties" />
    	
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
    		p:driverClassName="${datasource.driverClassName}" 
    		p:url="${datasource.url}" 
    		p:username="${datasource.username}"
    		p:password="${datasource.password}" />
    I hope that it helps someone ;-)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •