Google app engine flexible not load context path of Spring boot application - spring-boot

I have spring boot application and already deploy on GAE Flexible env.
In my application, I already set my application context path in application.properties file look like:
server.context-path=/myapp
And it work fine on tomcat and jetty embedded server.
But when I deploy to GAE flex env my application not work with context path that I already set on my application.properties file.
It auto use context path "/" in GAE domain.
Because I'm using dispatch to defined routing on GAE with multi microservice, so I have to define a specify context path for each service.
Anybody can help me in this case?
Thanks.

Related

SpringBoot Rest API: Works as Java Application, fails when deployed on tomcat

I have a Springboot project and it has a api which I can invoke from postman.
When I run the application using Main Class I'm able to hit the endpoint and get response.
But if I deploy it on tomcat using war of project the same endpoint says 404!
What am I missing?
There can be multiple possibilities
You didn't extended your application class to SpringBootServletInitializer. In this case, spring boot application will not be deployed to tomcat. To fix this add "extends SpringBootServletInitializer" to your main application class
You are hitting wrong url. Make sure you append your aplication name to url. Example - if http://localhost:8080/data works in your local, and your application name is app, you have to hit http://{{serverip:port}}/app/data when deployed
There is something wrong in application properties like DB configured is local and not accessible from tomcat etc. To check such issues, check your tomcat log file (/{{tomcat dir}}/logs/catalina.out

Setting management.endpoints.web.base-path to root when server.servlet.context-path is set

I'm trying to set the base path of the actuator to / so that PCF can access it.
I am Using SpringBoot 2.1.4
The applications all have configured context roots. Setting management.endpoints.web.base-path only changes the path relative to the application context root.
Is there a way to set the management path to root when there is an application context root? Or is there some way to hack SB2 so all requests to a path get routed to all my RequestMappings?
If by "so that PCF can access it", you mean Pivotal Apps Manager, and you are using a context path with your app then you need to apply this workaround.
That will allow you to use a context path with your app, but still expose the actuator endpoints so that Pivotal Apps Manager can consume them.
Hope that helps!

spring cloud config client set config url at property file

I have a spring cloud project. There are config server (config-srv), eureka server (eureka-srv) and some other service with business logic, let's call it main service (main-srv).
I'm packaging them into jars and run one by one. My apps get their properties from a file in the same directory with jars.
So, I'm setting properties to config-srv through "application-native.properties".
But if i want to change config-srv url (for example, i want http://localhost:9999), how can i share this url for all micro-services before they will boot ? I'm trying to share this url in "application-default.properties" but it makes no effect.
You can put the Spring Cloud Config server details in bootstrap.properties file in each microservices.
spring.application.name=microserviceName
spring.profiles.active=dev
spring.cloud.config.uri=http://localhost:9999
spring.cloud.config.username=your_username
spring.cloud.config.password=your_password
Go through the link to have more detail about spring cloud config
https://howtodoinjava.com/spring-cloud/spring-cloud-config-server-git/

Is it possible to expose a Spring MVC controller within a simple application context that is NOT a web application with a web.xml?

I would like to expose a Spring MVC controller in an application that will NOT be deployed in a web container like Tomcat. Is this possible? If so, can you please provide an example.
Spring boot has embedded servlet containers. This enables you to launch apps by executing a jar, instead of deployment to servlet container

Running multiple spring boot web app on tomcat

I am trying to deploy multiple spring boot web app on tomcat. All have the same application.properties.How can I split the configuration files for different app running on tomcat.
Spring Boot doesn't require an external Tomcat, because it contains its own embedded Tomcat. So you can run all of your application in it's own Tomcat on the same machine. All you have to do is to define different ports for your applications via server.port property.

Resources