Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To automatically wire a bean annotated with @ConfigurationProperties into SpEL expression in Spring Boot version 2.2.*, you can use the #{…} syntax with the bean name. For example, if you have a ConfigurationProperties bean named MyConfigProperties, you can refer to it in an expression like this:

@Value("#{myConfigProperties.someProperty}") private String someValue;

This will inject the value of the “someProperty” field of the MyConfigProperties bean into the “someValue” variable. Note that you need to provide the name of the bean in the expression, not the class name.