Run 2 containers in 1 spring boot application - spring-boot

Here're my case:
I'll use webflux starter and the default reactor netty server to serve my webflux app via 8080.
I'll use an embedded tomcat to serve my internal admin app which is servlet based, say on 7070.
Does spring boot support this by simply applying some properties settings?
I just checked:
If I have both starter-webflux and starter-tomcat, the tomcat will win at 8080.
If I change server.port = 7070, tomcat will start at 7070 and netty is still ignored.
Thanks
Leon

Related

How to deploy SpringBoot and Keycloak war on tomcat 9

I want to use SpringBoot 2.1.4.RELEASE, Keycloak 6.0.1, java 8 and deploy the war in an external tomcat 9 that also has other applications.
Keycloak documentation mentions -
https://github.com/keycloak/keycloak-documentation/blob/master/securing_apps/topics/oidc/java/spring-boot-adapter.adoc
'If you plan to deploy your Spring Application as a WAR then you should not use the Spring Boot Adapter and use the dedicated adapter for the application server or servlet container you are using. Your Spring Boot should also contain a web.xml file.'
Keycloak does not have tomcat 9 adapter.
is there any way to deploy the war on tomcat 9 ?
in my app, I don't have web.xml. Should I create an empty web.xml ?

Javamelody, spring boot management port and jetty

For security purposes, I'd like to have javamelody running on my app management port, not the main traffic port. This is a 1.5.13 spring boot app running jetty with some actuator endpoints enabled. I have set the actuator property management.port to something other than the server.port.
I can run javamdelody in a standalone jetty server on a third port using an approach like this github project. But three ports is a little wieldy in a micro-service context.
This stackoverflow post has answers for Tomcat, but not for Jetty. Any suggestions to run javamelody on the management port with Jetty?

Spring boot 2 with webflux and Router functions war does not work with standalone tomcat server

The application runs fine on spring boot embedded tomcat 8.5.28 (gradle bootRun) but when I create the war and put the same in stand alone tomcat server (8.5.28) the application always throws 404 for any of the routes configured.
The application runs fine on spring boot embedded tomcat 8.5.28 (gradle bootRun) but when I create the war and put the same in stand alone tomcat server (8.5.28) the application always throws 404 for any of the routes configured.
Spring Boot 2.0 does not currently support WAR deployment for WebFlux applications.
See the Spring Boot issue you created: https://github.com/spring-projects/spring-boot/issues/12455

Spring webflux on tomcat

I just created a new application using Spring boot 2 M7 and I'm using spring-webflux.
I built the application as an autoexecutable war that I can start in dev with java -jar app.war and also on a standalone tomcat server for UAT purpose.
In the web reactive reference doc, I read
To deploy as a WAR to a Servlet 3.1+ container, wrap HttpHandler with ServletHttpHandlerAdapter and register that as a Servlet. This can be automated through the use of AbstractReactiveWebInitializer.
Baeldung site also wrote about it and they describe a procedure to register a servlet that wrap the router for a standalone environment.
Using Spring boot tomcat starter, I didn't need to do anything : no code about booting the server necessary ; the app starts using the embedded server. In debug I saw NIO access so all seems fine.
I didn't try yet but what will happen on a standalone tomcat using Spring boot tomcat starter and webflux starter ? Is spring boot take care of everything (embbeded and standalone tomcat) ? how does it work ?

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