How to deploy a java Spring boot application for free

Souma picture Souma · Apr 24, 2020 · Viewed 7k times · Source

I wanted to know how a java web application made with spring boot or an app built just on servlets and jsp. Consider me as a beginner in this area. I know nothing about hosting an application and I'm trying to do it for the first time. I know there are videos and blogs about it but they use some technicalities sometimes which The just skip and assume that we know it already . If you have suggestions about what should I learn first in order to accomplish this then do suggest or if you have any links to particularly helpful blogs or videos that will do too. Thanking you all in advance.

Answer

frlzjosh picture frlzjosh · Apr 24, 2020

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