Skip to content

Instantly share code, notes, and snippets.

@bvulaj bvulaj/AppConfig.java
Last active Mar 14, 2018

Embed
What would you like to do?
Simple Field Injection w/ @value
@Configuration
public class AppConfig {
// Using SpEL
@Value("#{providerInfo.name ?: 'bar'}")
private String providerName;
// Injecting a Duration w/ a default
@Value("${timeout:500ms}")
private Duration timeout;
}
provider.name=foo
timeout=1000ms
@Component
public class ProviderInfo {
@Value("${provider.name}")
private String name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.