Solved

Spring Multiple Properties files

Posted on 2011-09-30
2
706 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 92
ejb wildfly example 2 111
Eclipse for Java EE development 2 68
Netbeans and org.apache.commons.lang3 issue 3 53
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.
Suggested Courses

734 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