Search Tutorials

Pivotal Cloud Foundry Tutorial - Deploy Spring Boot Application Hello World Example | JavaInUse

Pivotal Cloud Foundry Tutorial - Deploy Spring Boot Application Hello World Example

In this tutorial we be creating a simple Spring Boot Application and deploying to Pivotal Cloud Foundry(PCF).

Pivotal Cloud Foundry - Table Of Contents

Pivotal Cloud Foundry Tutorial - Quick Introduction Pivotal Cloud Foundry Tutorial - Setting up the Development Environment Pivotal Cloud Foundry Tutorial - Deploy Spring Boot Application Hello World Example Pivotal Cloud Foundry Tutorial - Understanding PCF Deployment Architecture Pivotal Cloud Foundry Tutorial - Deploying Spring Boot + MySQL Application to PCF Pivotal Cloud Foundry Tutorial - Deploying Spring Boot + RabbitMQ Application to PCF


This tutorial is explained in the below Youtube Video.

What is Pivotal Cloud Foundry? Why use it?

Some time back all the IT infrastructure was on premises. There we in house servers managed by an IT resource personnel or a service provider.
Then with advent of cloud services these software and hardware services are now delivered over the internet rather than being on premises.

Evolution of IT Services
Cloud Foundry is an open source, multi-cloud application platform as a service governed by the Cloud Foundry Foundation. The software was originally developed by VMware and then transferred to Pivotal Software, a joint venture by EMC, VMware and General Electric.
It is a service (PaaS) on which developers can build, deploy, run and scale applications.
Many Organizations provide the cloud foundry platform separately. For example following are some cloud foundry providers-
  • Pivotal Cloud Foundry
  • IBM Bluemix
  • HPE Helion Stackato 4.0
  • Atos Canopy
  • CenturyLink App Fog
  • Huawei FusionStage
  • SAP Cloud Platform
  • Swisscom Application Cloud

aws jar push

pcf jar push

Develop employee-producer to be deployed to PCF -

The maven project we will be creating is as follows-

The pom.xml with spring boot dependencies is as follows-

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi=""


		<relativePath /> <!-- lookup parent from repository -->







Define the domain class Employee
package com.javainuse.model;

public class Employee {
	private String empId;
	private String name;
	private String designation;
	private double salary;

	public Employee() {

	public String getName() {
		return name;

	public void setName(String name) { = name;

	public String getDesignation() {
		return designation;

	public void setDesignation(String designation) {
		this.designation = designation;

	public double getSalary() {
		return salary;

	public void setSalary(double salary) {
		this.salary = salary;

	public String getEmpId() {
		return empId;

	public void setEmpId(String empId) {
		this.empId = empId;


Expose the service using the Controller as-
package com.javainuse.controllers;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.javainuse.model.Employee;

public class TestController {

	@RequestMapping(value = "/employee", method = RequestMethod.GET)
	public Employee firstPage() {

		Employee emp = new Employee();

		return emp;

Finally define the Spring Boot Main class
package com.javainuse;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SpringBootHelloWorldApplication {

	public static void main(String[] args) {, args);
Compile and the run the as a Java application.
Go to localhost:8080/employee
Deploy Spring Boot Microservice
In previous tutorial we had seen how to download and install CF CLI. We had also seen how to login to PCF accoung using CF CLI.
  • Open the command terminal and use the following command
         cf login

    Cloud Foundry Login
  • It will ask for Cloud Foundry API. Enter The following API value-

    Cloud Foundry Login API
  • Next it will ask you for the Cloud Foundry credentials
    Cloud Foundry Credentials
  • Go to the project root location and using the following command push the employee-producer jar file to PCF for deployment
         cf push test-environment -p target\employee-producer-0.0.1-SNAPSHOT.jar

    Pivotal Cloud Foundry Push
  • We have pushed the spring boot jar file to PCF and deploy it for us.
    If we now go to the PWS web console, we will see that there is one application running in our development space.
    Pivotal Cloud Foundry Dev
  • Select the application and we will be taken to another page which has the route on which this application has been deployed.

    Pivotal Cloud Foundry Dev Space
  • Open this URL-
    Pivotal Cloud Foundry Dev Route
    Modify the URL by appending /employee to it.
    Pivotal Cloud Foundry Dev employee
So our application is successfully deployed to Pivotal Cloud Foundry.

Download Source Code

Download it -
Employee Producer Service