Hello everyone, this is my side by side blog on how to build my spring boot application in Ubuntu 16.04. I have already a project with basic spring boot specification which has build using gradle. This is my learning project on gradle and spring boot. So we all need a unix based os for deploying these to a cloud based hosting like digital ocean. So lets start.
These are the steps that i have already done.
1. Installed gradle in ubuntu 16.04 by following this article.
2. Copy the spring boot project to ubuntu box.
3. Installed Mongodb on Ubuntu machine by following this article
4. Installed Java 1.8
Oh.. Gradle !! Yeah it is a build automation tool that will take care of all the dependency and build tasks that we need to do while creating a project. Of course you can use other build tools like Maven,ant etc. But gradle comes with more power that other build tools in java.
Heard about gradlew ? It is worth looking into this if you are using gradle which will reduce your headache of installing gradle and will escape you from the version mismatch drama. Gradle vs gradlew ? . Gradle wrapper command will create gradlew.
Ok. lets come back to our Ubuntu Box. Our objective is to run spring boot in Ubuntu machine and the boot application is having a dependency on mongodb services. So we need to setup that as well.
You just need to go to the root directory where the build.gradle file exist and execute the command gradle bootRun. This will launch the spring boot process and you will something like below.
Yay !! spring boot has started !!.
One of my requirement for this spring boot project is that i want to run a selenium scrapper from this project that too headlessly using chrome. This link provides you more information on how can you install headless selenium.
Luckily Chrome has rolled out chrome-59 with headless feature which we can use for our experiment. Get the latest version of the chrome from this link.
So i have installed google-chrome 59 and all ready for running my headless chrome instance with selenium with spring boot. I have tested my application code in my windows machine and it worked like a charm. Now i am testing it on my Ubuntu server. fingers crossed !
It throws me unable to start exception. Mostly its because Ubuntu server is not able to start it on a graphical way. Lets investigate.
woo.. after a long 3-4 hours i could run the chrome 59 headless from selenium. Initially i was getting the same above error whatever i changed. I did a lot of googling to find out why the same exception coming. It was due to one of my big blunder of adding the wrong system property. I was adding the actual chrome installation path in the webdriver.chrome.driver property. Everything started working once i replaced the same with chrome-driver location.
For that i have downloaded the chrome-driver from the Chromium.org download site. And i did something similar including the symlink like this.
This particular script written in Github shows all the steps that we need to do to install the Chrome+selenium combo in your Unix boxes.
So here is my complete java code that running the selenium which invoke the headless google-chrome in Ubuntu machine.
And we need to pass the extra arguments for running the chrome in headless mode(Note that this feature available only google-chrome-59 onwards). The versions of the applications that used as follows.
Java - 1.8
Selenium - 3.*
google-chrome - 59
chromeDriver - 2.3
That's it guys. We have successfully ran our spring boot application which can invoke chrome instance headless way from selenium. Tune in for more. Thanks a lot.
These are the steps that i have already done.
1. Installed gradle in ubuntu 16.04 by following this article.
2. Copy the spring boot project to ubuntu box.
3. Installed Mongodb on Ubuntu machine by following this article
4. Installed Java 1.8
Oh.. Gradle !! Yeah it is a build automation tool that will take care of all the dependency and build tasks that we need to do while creating a project. Of course you can use other build tools like Maven,ant etc. But gradle comes with more power that other build tools in java.
Heard about gradlew ? It is worth looking into this if you are using gradle which will reduce your headache of installing gradle and will escape you from the version mismatch drama. Gradle vs gradlew ? . Gradle wrapper command will create gradlew.
Ok. lets come back to our Ubuntu Box. Our objective is to run spring boot in Ubuntu machine and the boot application is having a dependency on mongodb services. So we need to setup that as well.
You just need to go to the root directory where the build.gradle file exist and execute the command gradle bootRun. This will launch the spring boot process and you will something like below.
Yay !! spring boot has started !!.
One of my requirement for this spring boot project is that i want to run a selenium scrapper from this project that too headlessly using chrome. This link provides you more information on how can you install headless selenium.
Luckily Chrome has rolled out chrome-59 with headless feature which we can use for our experiment. Get the latest version of the chrome from this link.
So i have installed google-chrome 59 and all ready for running my headless chrome instance with selenium with spring boot. I have tested my application code in my windows machine and it worked like a charm. Now i am testing it on my Ubuntu server. fingers crossed !
It throws me unable to start exception. Mostly its because Ubuntu server is not able to start it on a graphical way. Lets investigate.
woo.. after a long 3-4 hours i could run the chrome 59 headless from selenium. Initially i was getting the same above error whatever i changed. I did a lot of googling to find out why the same exception coming. It was due to one of my big blunder of adding the wrong system property. I was adding the actual chrome installation path in the webdriver.chrome.driver property. Everything started working once i replaced the same with chrome-driver location.
For that i have downloaded the chrome-driver from the Chromium.org download site. And i did something similar including the symlink like this.
This particular script written in Github shows all the steps that we need to do to install the Chrome+selenium combo in your Unix boxes.
So here is my complete java code that running the selenium which invoke the headless google-chrome in Ubuntu machine.
And we need to pass the extra arguments for running the chrome in headless mode(Note that this feature available only google-chrome-59 onwards). The versions of the applications that used as follows.
Java - 1.8
Selenium - 3.*
google-chrome - 59
chromeDriver - 2.3
That's it guys. We have successfully ran our spring boot application which can invoke chrome instance headless way from selenium. Tune in for more. Thanks a lot.