33

I want to know where and how can I deploy a Java web application made with Spring Boot or an app built with servlets or JSP.

Consider me a beginner in this topic. If you have suggestions about what I should learn first in order to accomplish this then please share, also if you have any links to particularly helpful blogs or videos that will do too.

Thank you all in advance.

videomugre
  • 180
  • 2
  • 9
Dev
  • 794
  • 1
  • 9
  • 21
  • don't want know the name of the platforms where I can host. I wanted to learn the whole process from the scratch. I know that may not be possible here in one answer, but people can point me out to the correct direction by sharing some valuable tutorial or blog or videos etc. Thanks – Dev Apr 24 '20 at 11:17

6 Answers6

15

I too have used GCP to host a Spring-Boot service. I followed this article almost religiously provided by Spring Boot(https://www.baeldung.com/spring-boot-google-app-engine) as well as this github read me that includes extra information about preparing your service to be hosted onto GCP (https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard)

  • The main idea is that you will need to create a CLOUD SQL instance if you are using MySQL, and then add some configurations in your applications.properties (https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory)
  • You will need to package your Spring-Boot services to either a jar or a war. I used a war because I was able to find more resources. This is done in your pom.xml.
  • You will need to include all the right GCP packages to be able to host onto gcp in your pom.xml
  • You will need to create some sort of runtime configuration by creating an appengine/app.yaml file
  • You will need to extend a Servlet class in your main application file so that GCP has a main endpoint when any call is made to utilize your Spring-Boot services
frlzjosh
  • 410
  • 5
  • 17
5

You can use GCP (google cloud platform) App Engine for the deployment purpose. It's easy to learn and free to use for 1 year.

Deploy Spring Boot Application in App Engine standard

Saurav Kumar Singh
  • 1,352
  • 7
  • 18
5

Though all the answers were helpful, I found the process of deploying my spring boot app into Heroku is simpler. First of all we need to create a github repository for our project. and commit all the codes to github from STS. We have to have an account in Heroku. where we'll create a project which is currently empty-> Deploy -> choose Github under deployment method -> and choose the project we're trying to deploy -> Choose Deploy branch option under Manual Deploy.(you can enable automatic deploy if you want to deploy automatically after pushing an update in git). -> you're good to go.

This is only for an webapp with no database connectivities, for database related features we have to use add-ons like Heroku-postgres or jawssql .Once I do that part I'll update the answer.

here is a step by step guide: https://www.kindsonthegenius.com/2019/11/28/devops-ci-cd-pipeline-step-by-step-tutorial-springboot-github-heroku/

Dev
  • 794
  • 1
  • 9
  • 21
2

It depends on where you want to deploy the app.... If you use a private host you must generate a package and make a "manual" deploy to your own server.

The easiest way is to use Heroku. A cloud platform very user friendly for begginers. It has a free plan so you can host your app for free forever... with limitations. The apps fall asleep after 30 min of no use, for example. It's good for testing porpouses In order to use heroku you must know how to use git. I will assume you alredy know the git basics... otherwise I suggest you to learn it first.

1-Create heroku account and log in.

2-Search for New button -> create new app.

3-choose region and app name

4-You can navigate inside your app. Look for deploy (I think it automatically goes there when creating new app)

5-You have three ways to upload an app on heroku. Using git, github or container. For the first and the last one you must install heroku CLI. Follow this guideline https://devcenter.heroku.com/articles/heroku-cli#download-and-install

6.1-If you want to upload your app using github, click on github and follow steps... very easy

6.2- If you want to use git and heroku cli.. click on heroki CLI and follow steps.. (basically you need to "heroku login" and after commiting your work just "git push heroku master"....)

If everything works, your app is in the cloud and you can use it for free....

NOTE I think heroku only is able to deploy Springboot apps...

It's quite easy following some tutorial...

1

With scalingo.com you get 30 days free trial. That's where I managed to host my java app and mysql DB for free. It's only 30 days but it allows you to se how deployment works and it's definitely a valuable experience for beginners.

Google cloud platform is also a good option. I haven't used it but I now there you also have free trial for 1 year I believe.

Ivan Kirchev
  • 133
  • 1
  • 9
  • 1
    I don't want know the name of the platforms where I can host. I wanted to learn the whole process from the scratch. I know that may not be possible here in one answer, but people can point me out to the correct direction by sharing some valuable tutorial or blog or videos etc. Thanks – Dev Apr 24 '20 at 10:57
0

I feel Heroku and GCP are good solutions but you can try Azure as well for deployment of spring boot application as alternative. There are very good resources (documents) about how to achieve this. Azure gives 200$ credit in starting. Please refer below official document,

https://spring.io/guides/gs/spring-boot-for-azure/

Amit H
  • 49
  • 7