Announcement Announcement Module
Collapse
No announcement yet.
How To - @PropertySource reading multiple properties files... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How To - @PropertySource reading multiple properties files...

    Hello Guys..

    I have this configuration and work fine..

    Code:
    <beans profile="production">
    		<context:property-placeholder 
                                 location="classpath:/com/manuel/springframework/properties/*-production.properties" />
    		
    		<bean id="dataSource" 
    		      class="com.mchange.v2.c3p0.ComboPooledDataSource" 
    		      destroy-method="close">		
    ....
    You can see I am using a wildcard..
    *-production.properties

    When I do the same working with JavaConfig

    Code:
    @Configuration
    @Profile({"production"})
    @PropertySource({"classpath:/com/manuel/springframework/properties/*-production.properties"})
    public class SpringFrameworkDbProductionInfrastructureConfiguration {
    I get

    Code:
    Caused by: java.io.FileNotFoundException: class path resource 
    [com/manuel/springframework/properties/*-production.properties] 
    cannot be opened because it does not exist
    	at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:157)
    Practically the Wildcard is ignored...

    Therefore how I can around this?

    BTW indicating explicitly each .properties file work fine....but is verbose

    Code:
    @Configuration
    @Profile({"production"})
    // TODO 02 Resolve the wildcard...
    //@PropertySource({"classpath:/com/manuel/springframework/properties/*-production.properties"})
    @PropertySource({"classpath:/com/manuel/springframework/properties/c3p0-production.properties",
                                    "classpath:/com/manuel/springframework/properties/hibernate-production.properties",
                                    "classpath:/com/manuel/springframework/properties/mysql-production.properties"
    })
    public class SpringFrameworkDbProductionInfrastructureConfiguration {
    Thank You...
    Last edited by dr_pompeii; May 1st, 2013, 02:21 PM.
Working...
X