I am working in Spring, Java, Ant
web application. I am using Spring profiling to load properties based on the enironment. Below is the sample
@Profile("dev")
@Component
@PropertySource("classpath:dev.properties")
public class DevPropertiesConfig{
}
@Profile("qa")
@Component
@PropertySource("classpath:qa.properties")
public class TestPropertiesConfig {
}
@Profile("live")
@Component
@PropertySource("classpath:live.properties")
public class LivePropertiesConfig{
}
In web.xml, we can give the profile
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>
Now, my query is for every environment i need to create a separate Java class.
Question: Is it possible to have only one class like providing profile name as some binding parameter like @Profile({profile})
.
Also, let me know if there is other better option available to achieve the same.