Ask Your Question
0

What is the way to automatically wire a bean annotated with @ConfigurationProperties into the SpEL expression in spring-boot version 2.2.*?

asked 2022-03-31 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2023-01-14 12:00:00 +0000

scrum gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-03-31 11:00:00 +0000

Seen: 8 times

Last updated: Jan 14 '23