Java_Coder
Java_Coder

Reputation: 133

Difference between @Value and @ConfigurationProperties?

Difference between @Value and @ConfigurationProperties? In which scenario should I use @Value or @ConfigurationProperties? @RefreshScope will refresh properties value for both?

Upvotes: 1

Views: 2700

Answers (2)

Daniel Branco
Daniel Branco

Reputation: 127

I was questioning the same, to myself, and I found a concrete reason and why is better to use ConfigurationProperties over Value.

The main reason is that you could end with some text in the code forcing you to do full-text search to understand where a Value property is used.

You can find the whole explanation in in this lightweith reading: https://tuhrig.de/why-using-springs-value-annotation-is-bad/

Upvotes: 3

arvind Verma
arvind Verma

Reputation: 1

Insteead of using @Value annotation multiple time to read value from properties file .we can use @configurationProperties one time

Upvotes: 0

Related Questions