Publish Your Article Here

What is @ConfigurationProperties annotation in spring boot?

Spring Boot allows you to externalize your configuration so you can work with the same application code in different environments. You can use properties files, YAML files, environment variables and command-line arguments to externalize configuration. Property values can be injected directly into your beans using the @Value annotation, accessed via Spring’s Environment abstraction or bound to structured objects via @ConfigurationProperties.

Type-safe configuration properties

Using the @Value("${}") annotation to inject configuration properties can sometimes be cumbersome, especially if you are working with multiple properties or your data is hierarchical in nature. Spring Boot provides an alternative method of working with properties that allows strongly typed beans to govern and validate the configuration of your application.

Relaxed binding

Spring Boot automatically uses relaxed rules for binding Environment properties to @ConfigurationProperties beans. Meaning, there doesn’t need to be an exact match between the Environment property name and the bean property name. Imagine you have a bean property called allowCredentials you can use the following configuration in your properties.

  • allowCredentials: using standard camel case syntax.
  • allow-credentials: using dashed notation.
  • allow_credentials: using underscore notation.
  • ALLOW_CREDENTIALS: using upper case format.

@ConfigurationProperties example is in the next page.

<< Previous Program | Next Program >>

Spring-Boot Examples

  1. Spring-Boot initial setup.
  2. Spring-Boot hello world example
  3. What is spring-boot-starter-parent in Spring-Boot pom.xml file?
  4. What is @SpringBootApplication annotation in spring boot?
  5. What is in spring boot?
  6. What is @ConfigurationProperties annotation in spring boot?
  7. Spring Boot @ConfigurationProperties example
  8. Spring Boot @ConfigurationProperties Property Validation
  9. Difference between @ConfigurationProperties and @Value
  10. Spring boot web application configurations.
  11. How to run spring boot application through command line?
  12. How to run spring boot as a standalone application (non-web)?
  13. Spring boot property resolution order.
  14. Spring Boot – Profile based properties example.
  15. How to configure logback (SLF4J) logging to spring boot applications?
  16. How to update application context path in spring boot?
  17. How to disable spring logo banner in spring boot?
  18. Spring Data JPA with Spring Boot Applications - Oracle - example
  19. Spring Data JPA with Spring Boot Applications - MySql example
  20. How to configure Spring Boot to show Hibernate SQL Query in logs?
  21. Spring Boot – List all Beans loaded in the ApplicationContext
  22. How to load external property files into Spring Boot application?
  23. How to rename file in Spring Boot application?
  24. How to configure multiple DataSources (Databases) with Spring Boot and Spring Data?
Knowledge Centre
Difference between Enumeration and Iterator
The functionality of Enumeration and the Iterator are same. You can get remove() from Iterator to remove an element, while while Enumeration does not have remove() method. Using Enumeration you can only traverse and fetch the objects, where as using Iterator we can also add and remove the objects. So Iterator can be useful if you want to manipulate the list and Enumeration is for read-only access.
Famous Quotations
I don’t know the key to success, but the key to failure is trying to please everybody.
-- Bill Cosby

About Author

I'm Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment.

If you come across any mistakes or bugs, please email me to [email protected].

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java™ Platform Standard Ed. 8 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2018 by Nataraja Gootooru. All Rights Reserved.