Results 1 to 4 of 4

Thread: Using variables in applicationcontext.xml

  1. #1
    Join Date
    Dec 2004
    Posts
    5

    Default Using variables in applicationcontext.xml

    I'm sorry if this is the wrong forum. I've seen references in the user documentation to using "variables" in the applicationcontext.xml file. There are places where ${somevalue} is entered for the value of an element and that value appears to get pulled from another file. Could someone give me some information on how to do this in my own app? I've looked around, but can't seem to find how this is being accomplished. Thanks for helping a newbie!

    Thanks,
    joatmon

  2. #2
    Join Date
    Dec 2004
    Posts
    5

    Default

    Answered my own questions. Thanks!

    Answer!
    Last edited by robyn; May 19th, 2006 at 05:14 AM.

  3. #3
    Join Date
    Jan 2005
    Posts
    4

    Default

    I think it's not supported .Need it ?

  4. #4
    Join Date
    Dec 2004
    Posts
    5

    Default

    Code:
    	<!-- replace $&#123;&#125; with properties file values -->
    	<bean id="propertyConfigurer"
    		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    		<property name="location">
    			<value>classpath&#58;database.properties</value>
    		</property>
    	</bean>
    	
    	<!-- data source -->
    	<bean id="dataSource"
    		class="org.apache.commons.dbcp.BasicDataSource">
    		<property name="driverClassName">
    			<value>$&#123;db.driverName&#125;</value>
    		</property>
    		<property name="url">
    			<value>$&#123;db.url&#125;</value>
    		</property>
    		<property name="username">
    			<value>$&#123;db.username&#125;</value>
    		</property>
    		<property name="password">
    			<value>$&#123;db.password&#125;</value>
    		</property>
    	</bean>
    add propertyConfigurer to your bean defenition xml and then,you can put your ${somevalue} to database.properties that under classpath

Similar Threads

  1. Configuring static variables
    By cmgharris in forum Container
    Replies: 21
    Last Post: Jun 13th, 2012, 06:57 AM
  2. Environment Variables in Spring?
    By dleal in forum Container
    Replies: 14
    Last Post: Apr 12th, 2007, 06:33 AM
  3. Environment Variables in Spring?
    By dleal in forum Data
    Replies: 4
    Last Post: Aug 9th, 2005, 04:58 PM
  4. Standard Context Variables
    By jackcholt in forum Web Flow
    Replies: 1
    Last Post: May 24th, 2005, 03:10 PM
  5. Named Bind Variables
    By james.estes in forum Data
    Replies: 4
    Last Post: Sep 6th, 2004, 10:11 AM

Posting Permissions

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