Skip to main content
InterviewHubPRO
Section Overview
Q12

Question 12 of 50

Part 2: Persistence, Transactions & Security (11 - 24)

24%
Spring Boot & Microservices (50 Qs)•Part 2: Persistence, Transactions & Security (11 - 24)

What is `@ConfigurationProperties` and how is it superior to `@Value`?

junior LevelCode ExampleState ManagementSecurity & AuthDatabases & SQL

In Simple Words:

  • @Value: Weakly typed, error-prone SpEL string injections (e.g. @Value("${app.timeout}") private int timeout;).
  • @ConfigurationProperties: Strongly typed, supports hierarchical YAML binding, validation via @Validated, and IDE autocomplete.
java
@ConfigurationProperties(prefix = "app.payment")
@Validated
public record PaymentConfig(
    @NotBlank String gatewayUrl,
    @Positive int timeoutMs,
    boolean mockEnabled
) {}