How to run your Spring Boot application on OpenShift?

05.10.2015 10:41:29

How to run your Spring Boot application on OpenShift? Spring Boot documentation is currently outdated, so I created this howto. Configuration files use "openshift" Spring and Maven profile. I think that it's very useful. If you don't use Spring and/or Maven profiles, you can leave the files as it is. If you have differently named profiles (like "prod" or "Production" etc.), just simply change the files.

First create a DIY application:

rhc app create OPENSHIFT_APPLICATION_NAME diy-0.1

You will get GIT_REMOTE_URL.

Copy to your application .openshift directory and call:

git remote add openshift -f GIT_REMOTE_URL

Add these files:


mvn clean package -P openshift -s .openshift/settings.xml -DskipTests=true


nohup java -jar target/*.jar --server.port=${OPENSHIFT_DIY_PORT} --server.address=${OPENSHIFT_DIY_IP} &


PID=$(ps -ef | grep java.*\.jar | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
    client_result "Application is already stopped"
    kill $PID


<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns=""

And finally call:

git update-index --chmod=+x .openshift/action_hooks/build
git update-index --chmod=+x .openshift/action_hooks/start
git update-index --chmod=+x .openshift/action_hooks/stop
git add .
git commit -m "moved to openshift"
git push -f openshift master:master

EDIT: Just made a GitHub repo with a sample application which contains all these steps:

© Jiri Pinkas | this project on GitHub | related: JavaVids | Maven Central Repository Search | Java školení

Top Java Blogs is a Java blog aggregator (with English-written blogs only) focused on Java SE, Java EE, Spring Framework and Hibernate.