Professional Documents
Culture Documents
Springboot Ond Openshift
Springboot Ond Openshift
About (/)
Curriculum (/curriculum)
Blog
(/blog)
(http://www.linkedin.com/in/fabiomafoletti) (http://twitter.com/fubbyo)
(https://github.com/fabiomafoletti/) (skype:fabio-mafoletti?add)
package me.fabiomaffioletti.bootjava8;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class Bootjava8Application {
public static void main(String[] args) {
SpringApplication.run(Bootjava8Application.class, args);
}
@RestController
static class Bootjava8Controller {
@RequestMapping("/")
public ResponseEntity<String> bootjava8() {
return ResponseEntity.ok("I'm running on Oracle Java 8");
}
}
}
Now move to the the Spring application directory and add the remote OpenShift repository in this way:
git init
git remote add openshift -f ssh://566982c489f5cfaac2000085@bootjava8-fabiomaffi
oletti.rhcloud.com/~/git/bootjava8.git/
Updating openshift
remote: Counting objects: 25, done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 25 (delta 1), reused 25 (delta 1)
Unpacking objects: 100% (25/25), done.
From ssh://bootjava8-fabiomaffioletti.rhcloud.com/~/git/bootjava8
* [new branch]
master
-> openshift/master
Now you can merge from the OpenShift repository like this:
git merge openshift/master -s recursive -X ours
And as result in the project directory, there should be an .openshift directory, that is important, and
some other directories ( diy, misc) that you can delete or put into .gitignore.
Edit the build action hook and put there the instructions to install Maven and Oracle Java 8:
#!/bin/bash
cd $OPENSHIFT_DATA_DIR
if [ ! -d apache-maven-3.3.3 ]; then
wget http://www.eu.apache.org/dist/maven/maven-3/3.3.3/binaries/apache-maven3.3.3-bin.tar.gz
tar -zxf apache-maven-3.3.3-bin.tar.gz
fi
if [ ! -d jdk1.8.0_65 ]; then
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=acce
pt-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u65-b16/jd
k-8u65-linux-i586.tar.gz
tar -zxf jdk-8u65-linux-i586.tar.gz
fi
With these Maven and Oracle Java 8 will be installed in the $OPENSHIFT_DATA_DIR directory. The
installation will run only the rst time the project is pushed to the OpenShift git repository.
Create a le named settings.xml in the .openshift directory and put this content into it:
<settings>
<localRepository>$OPENSHIFT_DATA_DIR</localRepository>
</settings>
The application will build, run its tests and start. It is possible to tail the logs by doing:
rhc tail bootjava8
Resources
Source code is available here (https://github.com/fabiomaoletti/bootjava8)
3 Comments
fabiomaoletti.me
Recommend 2
Share
Login
Sort by Best
24 days ago
Good article,
By chance don`t you know what can cause
Error: Unable to access jarle /var/lib/openshift/56e7312b2d52716b2d00021d/approot/runtime/repo//target/*.jar
Thank you
Reply Share
4 days ago
Basanta Thapa
Reply Share
a month ago
Hi Fabio I followed your tutorial and successfully setting up everything and now while I
run, I am getting connection timeout, it's failing the startup.
MY db is : msyql
Reply Share
ALSO ON FABIOMAFFIOLETTI.ME