Using multiple dispatcher servlets / web contexts with spring boot

后端 未结 2 1935
一个人的身影
一个人的身影 2020-12-04 18:40

I created a spring boot application with a parent context (services) and child context (spring-webmvc controllers):

@Configuration
public class MainApiApplic         


        
2条回答
  •  难免孤独
    2020-12-04 19:05

    Create a ServletRegistrationBean that declares the servlet and its mappings. You will probably also want to exclude DispatcherServletAutoConfiguration from the autoconfigurations called, because it will register a DispatcherServlet at / and override yours

    EDIT Despite my comment below saying you might not need this, unless you need your APIs running on separate ports (and it doesn't sound like you do), Dave Syer, one of the authors of Spring Boot, answered a very similar question here: Configure multiple servletcontainers/servlets with spring boot

提交回复
热议问题