Announcement Announcement Module
Collapse
No announcement yet.
@PropertySource post processing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @PropertySource post processing

    I'm using Spring 3.1RC1 with multiple @Profile's and multiple @PropertySource's that is working. What I would like to do is reference a key in on properties file in another properties file loaded later. I have not figured a way to hook into the application after both @PropertySource's has been "read" and programmatically read both PropertySources so I can actually perform the replacements of key's in values. In common.properties some values references a key in dev/prod.properties that I would like to replace. So my expected result when profile "dev" is activated is: services.payment.url=http://dev-server:4000//PaymentPath-WAR-1.1.

    Where can I hook in a have both propertysources available so I can replace value's containing a key with the value of that key? Any help is appreciated.


    My setup:
    Code:
    @Configuration
    @EnableWebMvc
    @PropertySource({"classpath:/properties/common.properties"})
    @ComponentScan(basePackages = "some.package",
    		excludeFilters = {@ComponentScan.Filter(Configuration.class)})
    public class ServiceConfig {
    
    	@Configuration
    	@Profile(Constant.DEV_PROFILE)
    	@PropertySource({"classpath:/properties/dev.properties"})
    	static class DevConfig {
    	}
    
    	@Configuration
    	@Profile(Constant.PROD_PROFILE)
    	@PropertySource({"classpath:/properties/prod.properties"})
    	static class ProdConfig {
    	}
    }
    common.properties file:
    Code:
    services.payment.url = ${services.base.url}/PaymentPath-WAR-1.1
    dev.properties file:
    Code:
    services.base.url = http://dev-server:4000
    prod.properties file:
    Code:
    services.base.url = http://prodserver:4000
Working...
X