The application

This lesson uses an existing application,, as its starting point. It is a simple Spring Boot application using Spring MVC to expose a RESTful endpoint. It additionally exposes the Spring Boot Actuator endpoints, including the Kubernetes probes, health, info, and env.

Examine the application

The main branch contains the starting point for this lesson. Please download/clone it to proceed. The solution branch contains the application as it should look at the end of this lesson.

Let’s examine the main branch’s contents:

  • pom.xml
    • The Maven build file for the project.
  • src/main/java/org/acme/externalconfig/rest/
    • The Spring MVC class exposing the /hello REST endpoint.
    • Injects the hello.greeting property and uses it in the response of the /hello endpoint.
  • src/main/resources/application.yml
    • Configuration for the application, including a default value for the hello.greeting property used by HelloController.
  • src/test/java/org/acme/externalconfig/rest/
    • Tests for the /hello endpoint exposed in the HelloController class.

Run the application locally

Let’s run the application locally to become familiar with it. Open a terminal to the project’s root directory and execute ./mvnw clean package spring-boot:run on Linux/macOS or mvnw.cmd clean package spring-boot:run on Windows. This will compile the application, run all the tests, and then expose the HTTP endpoints on port 8080.

Now, let’s try interacting with the endpoints by opening a browser window or using the curl command from another terminal. The following shows what the values of some of the endpoints should look like:

  "property": {
    "source": "Config resource 'class path resource [application.yml]' via location 'optional:classpath:/'",
    "value": "Hello"

NOTE: There is most likely more data in the http://localhost:8080/actuator/env/hello.greeting response. The output is trimmed for brevity.

The /actuator/env/hello.greeting endpoint is the Spring Boot Actuator Environment endpoint. It allows retrieving information about the entire environment or just a single property. This information includes the current value of a property and where it was resolved.

In our case, you can see that the current value of hello.greeting is Hello, and it was resolved from the application.yml file on the classpath, which originated in src/main/resources/application.yml.

Stop the application using CTRL-C before moving to the next section.

Eric Deandrea
Eric Deandrea
Sr. Principal Developer Advocate
Eric is a Sr. Principal Developer Advocate at Red Hat, focusing on Application Development technologies such as Quarkus, Spring Boot, as well as the rest of Red Hat's Runtimes portfolio. Prior to joining Red Hat, Eric spent many years in the financial services & insurance industries. Eric also enjoys contributing to various open-source projects, including Quarkus and the Spring ecosystem. Outside of work, Eric enjoys ice hockey and martial arts. He holds a black belt in Kempo Karate.