5.2. Available ValueSource annotations

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.

[Note]Note
Explicit ordering of ValueSource annotations is not yet supported but will be soon. See SJC-170 and SJC-171 for details.