Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Spring Multiple Properties files

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
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 learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

722 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