Solved

Spring Multiple Properties files

Posted on 2011-09-30
2
691 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
login jsp example 24 84
Desingning Refactoring existing code 2 31
How to convert from xls to xlsx using java 7 84
Eclipse Java import and method not resolved 4 73
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

679 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