Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments. Now that you understand how to set a property and inject it into your application using the annotation you need to understand the property source order. RestController public class GreetingController ! Spring Boot Property Source Order Any value that you want to be configurable should move to configuration. To make this accessible on the root context annotate it with you were to run this application and open you should see the text Hello, World! While this works and is a bit of a contrived example this greeting message might not be something you want to hard code. The first thing you will need to do is to create a new class named GreetingController and to mark it as a Next, create a method named home that returns the hard coded String “ Hello, World”. Spring Boot Annotationįor this example I am using a simple application that I bootstrapped using and the only dependency you need is Spring Web. You will also learn about Spring Boot’s property source order and how to override configuration values. In this article you will learn about how to set configuration properties and values and then inject them into your application using the annotation. A property source, simply put, is a source for your configuration such as Java properties files, YAML files, environment variables, command line arguments and more. Spring Boot allows you to configure your application through a number of property sources. □ The video tutorial for this blog post can be found above or you can click here to watch it on YouTube.
0 Comments
Leave a Reply. |