I have a situation where there is a set of beans tied to an environment. i.e. When my application runs in a test environment i have to load a specific set of beans and when it runs in production it has to load a specific set of beans.
Essentially, i can have two xml configuration files with environment specific beans or can have a single file with all the beans. But the problem is how do I load/switch beans based on the environment ?
I am using standalone Spring container to load all my beans. One option that I thought of was to have two files in separate folders (test, prod) and then specify enviornment specific folder when I initialize my container.
Is there a tool or a better way (annotations ?) to achieve this ?Code:private final static ApplicationContext springContext = SpringApplicationContextSupport.prepareSpringApplicationContext("classpath*:spring/<test or prod>/config.xml" );
Appreciate your help


Reply With Quote