Other options ;for application configuration values

Until now, the approaches ;we took to ;configure application properties was using the key value pairs from either application.properties or application-{profile-name}.properties.

Spring Boot provides a number of other ways to configure application properties.

Listed here are some of the important ways of providing application configuration:

  • Command-line arguments
  • Creating a system property with the name ;SPRING_APPLICATION_JSON and including the JSON configuration
  • ServletConfig init parameters
  • ServletContext init parameters
  • Java System properties (System.getProperties())
  • Operating system environment variables
  • Profile-specific application properties outside of .jar, somewhere in the classpath of the application (application-{profile}.properties)
  • Profile-specific application properties packaged inside your .jar (application-{profile}.properties and YAML variants)
  • Application properties outside the .jar
  • Application properties packaged inside the .jar

More information can be found in the Spring Boot documentation at ;http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-external-config.

The approaches at the top of this list have higher priority than those at the bottom of the list. For example, if a command-line argument with the name spring.profiles.active is provided when launching the application, it would override any configuration provided through application.properties because command-line arguments have higher preference.

This provides great flexibility in determining how you would want to configure your application in different environments.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset