Review the base structure of the application
For your convenience, this scenario has been created using the OpenShift Launcher found here. This launcher will automatically generate a zip file of a project that's in a ready-to-deploy state. We've selected the
Externalized Configuration project and will be using the Spring Boot runtime option.
1. Understanding the Application
The project is a simple Greeting application, where a user inputs a fruit and is greeted by our service. Opening up our
greeting-service/src/main/java/io/openshift/booster/service/FruitController.java file we can see the logic used to respond to our user. The interesting part of this logic is right here, where we retrieve the message:
String message = String.format(properties.getMessage(), name);
If we take a closer look at this
properties object, we see that it's of type
MessageProperties. When we look at that file
greeting-service/src/main/java/io/openshift/booster/service/MessageProperties.java we see an annotation linking to a configuration file,
@ConfigurationProperties("greeting"), which is pointing to our
application-local.properties file contains only one property,
greeting.message. This is the message that we return and display to the user. In order to get an understanding of the flow, let's run the application locally. First cd into the project directory and build the project:
When the application finishes building click the local web browser or click here. You should see the same message that is in the
Be sure to stop the application with
cd back into the main directory before we continue.
You have now successfully executed the first step in this scenario. in the next step we're going to be deploying the project and testing it our for ourselves, as well as modifying this greeting through External Configuration.