I was trying to deploy Spring Boot application on Google App Engine (standard environment). At first I cloned example app from this nice tutorial https://springframework.guru/spring-boot-web-application-part-4-spring-mvc/
For example I called http://localhost:8080/products and template with data was displayed.
So everything ran without problems, I was able to call all controller methods locally. Then I decided as experiment to deploy it on GAE. I adjusted pom.xml according to instructions from here https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/appengine-standard-java8/springboot-appengine-standard
It means I excluded Tomcat dependency, changed packaging from jar to war, created appengine-web.xml file etc. As next step, I created GAE project in GAE console and copied APP ID into appengine-web.xml. Then I ran mvn clean package and war was created in target folder. Finally I started with GAE deployment and it also went smoothly without errors.
My app is now deployed on this URL https://20180109t135551-dot-oe-gae-test.appspot.com/
If you try it, you will see Hello World in browser. But if I try to call /products controller method like this https://20180109t135551-dot-oe-gae-test.appspot.com/products I get "not found" error.
Can you give me advice on which URL should I call my controller methods? Did I forget to implement something like web.xml servlet mapping? Or is it some specific Spring Boot - Google App Engine problem?
I will be grateful for any hint.
Thank you all in advance
Following this steps translates into the following for the code:
In pom.xml, change
<packaging>jar</packaging>
to<packaging>war</packaging>
In the package
guru.springframework
add this class:Code:
Find this dependency in the POM:
And add these lines:
Exclude Jetty dependencies and include the Servlet API dependency:
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope> </dependency>
Add the App Engine Standard plugin:
appengine-web.xml
insrc/webapp/WEB-INF
with these contents:<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> <threadsafe>true</threadsafe> <runtime>java8</runtime> </system-properties> </appengine-web-app>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency>
and modifying it this way:
In
src/main/resources
add a logging.properties file with:and inside
src/main/webapp/WEB-INF/appengine-web.xml
paste this:EDIT:
For steps
3
and7
you can also go to the project explorer (in case you're using Eclipse) and navigate to Libraries -> Maven dependencies and select each library individually (jul-to-slf4j-1.7.25
andspring-boot-starter-tomcat-1.5.3.RELEASE
in my case). Right click on each library and go to Maven -> Exclude Maven artifact... And click Ok. This will have the same effect on the POM as editing.