Deploying JAVA Spring Boot Application to the SAP BTP Cloud Foundry Instance

Let's dive into deploying a simple REST Controller to the BTP Cloud Foundry Instance. If you have a trial BTP account, this will be a great opportunity to follow along and understand the process. Hopefully, by the end of this tutorial, not only will I have a clearer grasp of the deployment process, but it might also help someone else facing similar challenges.

Step 1.

Before we begin, I highly recommend bookmarking the following resource:

SAP Cloud SDK | SAP Cloud SDK
SAP Cloud SDK is a one-stop shop for developing and extending SAP applications in the cloud.

Step 2.

Let's ensure your development environment is set up correctly. One common issue is the absence of essential tools like Maven and CF on your local machine. You can find installation instructions for these tools here:

Maven – Welcome to Apache Maven
Installing the cf CLI | Cloud Foundry Docs

Step 3.

Create a folder where your new Spring Boot project will reside.

Step 4.

Follow the instructions provided in the documentation to initialize your Spring Boot project. Make sure to input the required information as prompted.

mvn archetype:generate "-DarchetypeGroupId=com.sap.cloud.sdk.archetypes" \
    "-DarchetypeArtifactId=spring-boot3" \
    "-DarchetypeVersion=RELEASE"

Step 5.

Execute the necessary commands to run the downloaded sample project locally.

mvn clean install
cd application/
mvn spring-boot:run -D"spring-boot.run.profiles"=local

You should see the application successfully running once this process is complete.

Step 6.

Verify that the application is running locally by accessing it via http://localhost:8081/

💡
In my specific example, I've altered the port for the application to 8081, whereas the default value is 8080. You can make the corresponding changes in the /application/src/main/resources/application.yml file
0:00
/0:27

You can also interact with the application using tools like Postman.

0:00
/0:26

Step 7.

Find the Cloud Foundry endpoint for your BTP instance and log in using the Cloud Foundry API.

Please refer to the official documentation where it is required.

Getting started with the cf CLI | Cloud Foundry Docs

Step 8.

Now, let's push the application to your Cloud Foundry instance.

Step 9.

Once the deployment is complete, you can check the status of your application using the BTP cockpit.

0:00
/0:47