Last active
March 14, 2018 22:18
-
-
Save bvulaj/f9ba5834861cab937cfa99cde22f19d1 to your computer and use it in GitHub Desktop.
Simple Field Injection w/ @value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider.name=foo | |
timeout=1000ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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