Solved

Spring Multiple Properties files

Posted on 2011-09-30
2
634 Views
Last Modified: 2012-05-12
Hello,
Is it possible have multiple physical properties files loaded into the same property class ?
I currently have file
   queries.fec.properties
and want to split it into two files
   queries.fec.qa1.properties
   queries.fec.qa2.properties

and have the contetns loaded into the same Properties fecSql instance ?

public abstract class AbstractDao {
      
      protected Properties fecSql = null;
      protected Properties posSql = null;

      public void setFecSql(Properties props){this.fecSql = props;}
      public void setPosSql(Properties props){this.posSql = props;}
}

//where doa-config.xml has
<util:properties id="fecSql" location="classpath:sql/queries.fec.properties" />
<util:properties id="posSql" location="classpath:sql/queries.pos.properties" />

<bean id="abstractDao" class="com.cme.citps.dataAccess.AbstractDao" abstract="true">
          <property name="fecSql" ref="fecSql" />
          <property name="posSql" ref="posSql" />
 </bean>

//and the properties are referenced by

public class FECDetailsDao extends AbstractDao {
String dsName = this.connectionUtil.getProperty(this.fecSql,CITPSConstants.DATASOURCE_PREFIX, env, exchange);
}
0
Comment
Question by:Waponi
  • 2
2 Comments
 

Accepted Solution

by:
Waponi earned 0 total points
ID: 36932883
Remove the old reference to the single properties file
Example,
<util: properties id="fecSql"
location="classpath:sql/queries.fec.properties" />

And add PropertiesFactoryBean, include the new properties files
Example,
<bean id="fecSql"
Class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="ignoreResourceNotFound" value="true"/>
    <property name="locations">
        <list>
            <value>classpath:sql/queries.fec.ps.properties</value>
            <value>classpath:sql/queries.fec.qa.properties</value>
            <value>classpath:sql/queries.fec.default.properties</value>
        </list>
          </property>
</bean>
0
 

Author Closing Comment

by:Waponi
ID: 36932886
Solution, add PropertiesFactoryBean
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now