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

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

Related

Is there a way I can integrate the spring boot application jar to another servlet application?

I have created a spring boot application with a few endpoints and want to make that endpoint to the existing servlet application without deploying it separately. So I want to create a jar from the spring boot app and use that jar in the servlet project. How can this be done? Any suggestion would be really helpful.

Add a RESTful API using Spring Boot to an existing webapp running on Tomcat

I would like to add a RESTful API using Spring Boot to an existing webapp running on Tomcat. I have tried to use the SpringBootServletInitializer in order simplify the integration. However, when doing so Spring Boot seems to interfere with the existing webapp (e.g., / doesn't work as it used to any more).
Is it possible somehow to configure the Spring Boot integration so that it only handles endpoints that starts with /api and ignores everything else?
Also, is it possible to use the SpringBootServletInitializer for this?
The existing servlets are registered with servlet-mappings using the web.xml file.

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 ?

Using Spring Boot Thymeleaf by do not run as a web application

I have a Spring Boot application that uses Thymeleaf for email templating. My application is not a web application though.
However, when including the spring boot starter thymeleaf dependency:
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
Spring MVC is transitively included and eventually Servlet.class in my class path signaling that my application is a web application... which then has the undesirable result of running my application in the Tomcat servlet container (by default on port 8080).
How can I use the features of Spring Boot Thymeleaf (such as configuring in a props file ala https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html) without my application running as a web application?
Setting the following property as follows prevents the Spring Boot application from running as web application:
spring.main.web-environment=false

spring boot without web server but with management server

we have many services developed with spring boot, some are web services with a servlet container and some are services without a servlet container.
we don't use #EnableAutoConfiguration but we add only the auto configurations we need because our classpath is a mess and full auto configuration may create many beans we don't really need.
on services that don't need a servlet container we still want to have actuator and management server, so we register EndpointWebMvcAutoConfiguration but it has a condition on web application and does not create the management server.
of course i could just add EmbeddedServletContainerAutoConfiguration and just have a servlet container that does nothing but i don't like to do that.
Any idea how to cause spring boot to create the management server even on non web environment?
Thank you

Resources