I have a Spring-Boot-Application as a multimodule-Project in maven. The structure is as follows:
Parent-Project
|--MainApplication
|--Module1
|--ModuleN
<
You could autowire and use the Enviornment bean to read the property
@Configuration
@PropertySource(value = "classpath:tmdb.properties")
public class TMDbConfig {
@Autowired
private Environment env;
public String getApiKey() {
return env.getRequiredProperty("moviedb.tmdb.api-key");
}
}
This should guarantee that property is read from the context when you invoke the getApiKey()
method regardless of when the @Value
expression is resolved by PropertySourcesPlaceholderConfigurer
.