@PropertiesValueSource
@EnvironmentValueSource
@SystemPropertiesValueSource
ValueSource
annotations may be used in conjunction:
@Configuration @EnvironmentValueSource @SystemPropertiesValueSource @PropertiesValueSource("classpath:com/acme/db.properties") public class AppConfig { @ExternalValue("datasource.username") String username; @Bean public TestBean testBean() { return new TestBean(username); } }
In this example, datasource.username
will be looked for in
db.properties
, in the set of environment variables present at runtime
and in the system properties.