My Spring boot app has this application structure:
It can be achieved in multiple ways, refer below.
@Configuration
@PropertySource("classpath:application.properties")
public class EntityManager {
@Value("${language}")
private static String newLang;
@Bean
public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
return new PropertySourcesPlaceholderConfigurer();
}
}
OR
@Configuration
@PropertySource("classpath:application.properties")
public class EntityManager {
@Autowired
private Environment env;
public void readProperty() {
env.getProperty("language");
}
}