Config Server for Pivotal Cloud Foundry (PCF) is an externalized configuration service, which gives us with a central place to manage an application’s external properties across all environments.

Spring cloud config client applications can use Config Server to manage configurations across environments.

In this tutorial, let’s deploy a sample spring cloud config client application (say..Pet Store App) which binds to Config Server.

Table of contents

  1. Prerequisites
  2. Create spring boot starter application
  3. Deploy the application to PCF
  4. Test
  5. Summary


  • An account on Pivotal Cloud Foundry (PCF). You can create one here.
  • PCF Command Line Interface (CLI) installed on your computer. PCF CLI can be found in tools section of your PCF account.
  • For this tutorial I will be using cloudfoundry config service named my-config-server. You can refer the guide here to cregister the config service.
  • my-config-server is registered with the properties file which is in GIT.

Create spring boot starter application

Building the bare bone Spring Boot Service is simple when Spring Initializr is used. Spring Initializr generates spring boot project with just what you need to start quickly! Let’s start off with one.

Create a Spring Boot starter project using Spring Initializr

Let’s utilize the pre-configured Spring Initializr which is available here to create pcf-config-client-pet-service starter project.

Click on Generate Project. This downloads a zip file containing pcf-config-client-pet-service project. Import the project to your IDE.

Add a Rest Controller to read the value from properties file

Let’s add a rest controller class which exposes a HTTP GET method pet(). Here, the pet() method returns the value of the variable pet which is configured to dog in dev environement.

public class MyController {

  public String pet;

  public String pet() {
    return String.format("My pet is %s", pet);

Add a rest controller to read data from json file

Let’s Update the rest controller class with another GET service petDetails(). Here, the petDetails() returns the contents of petDetails.json file of dev environment.

  private PlainTextConfigClient configClient;

  public String petDetails() throws IOException {

    try (InputStream input = configClient.getConfigFile("petDetails.json").getInputStream()) {
      return StreamUtils.copyToString(input, Charset.defaultCharset());

Deploy the application to PCF

Create manifest.yml file for deployment

Let’s create manifest.yml file and specify the configuration details like JRE version, path of the application jar file, properties files being referenced as shown below. This file will be used for deployment to PCF.

- name: pet-service
  random-route: true
  instances: 1
  path: target/pcf-config-client-pet-service-0.0.1-SNAPSHOT.jar
  memory: 1G
  env: petDetails
    JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 13.+ } }'
    - my-config-server
  • path:
  • services:

Deploy Pet Store App to cloudfoundry

Deploy pcf-config-client-pet-service-0.0.1-SNAPSHOT.jar to PCF using the cf push command.

$ cf push -f manifest.yml


Pushing from manifest to your-org / space dev as
Using manifest file M:\pcf-config-client-pet-service\manifest.yml
Getting app info...
Creating app with these attributes...
+ name:        pcf-config-client-pet-service
  path:        M:\pcf-config-client-pet-service\target\pcf-config-client-pet-service-0.0.1-SNAPSHOT.jar
+ instances:   1
+ memory:      1G
+   my-config-server

Creating app pcf-config-client-pet-service...
Mapping routes...
Binding services...
Waiting for app to start...

Check the route of the Pet Store App

Once the deployment is completed successfully, you can check the assigned route of the app using cf app command.

$ cf app pcf-config-client-pet-service



Test pet() method

$ curl -i -X GET
My pet is cat

Test petDetails() method

$ curl -i -X GET
Dog people know dog language


Congratulations! You just created a new spring boot rest application which utilizes Config Server for it’s configuration.

Your feedback is always appreciated. Happy coding!