Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Spring Multiple Properties files

Posted on 2011-09-30
2
Medium Priority
?
806 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

916 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