Announcement Announcement Module
Collapse
No announcement yet.
p: property with data coming from a .properties file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Is it not possible or nobody knows?

    Thanks.

    Comment


    • #3
      Perhaps you should try asking a specific question?

      Comment


      • #4
        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.

        Comment


        • #5
          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 ;-)

          Comment

          Working...
          X