This is a part of my config class:
@Configuration
@PropertySource("classpath:properties.properties")
public class DataBaseConfig {
@Resource
private Environment env;
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
//some properties getting
String userName = env.getProperty("username");
dataSource.setUsername(userName);
return dataSource;
}
}
The problem is that SystemEnvironmentPropertySource
contains "username" property too, and it's getting processed before ResourcePropertySource
, based on my property file, because of propertySources list order. So the wrong value of "username" property is loaded. What's the way to get the properties in file to be processed before the system environment properties?