WebMvcAutoConfiguration
DispatcherServletAutoConfiguration 이 설정 클래스가 먼저 실행되고
WebMvcAutoConfiguration 실행
클래스패스에 @ConditionalOnClass({DispatcherServlet.class})
해당 클래스 존재해야함
DispatcherServlet 을 빈으로 등록하고 있다
@Bean(
name = {"dispatcherServlet"}
)
public DispatcherServlet dispatcherServlet(WebMvcProperties webMvcProperties) {
DispatcherServlet dispatcherServlet = new DispatcherServlet();
dispatcherServlet.setDispatchOptionsRequest(webMvcProperties.isDispatchOptionsRequest());
dispatcherServlet.setDispatchTraceRequest(webMvcProperties.isDispatchTraceRequest());
dispatcherServlet.setPublishEvents(webMvcProperties.isPublishRequestHandledEvents());
dispatcherServlet.setEnableLoggingRequestDetails(webMvcProperties.isLogRequestDetails());
return dispatcherServlet;
}
spring mvc 에 대한 환경설정을 위한 설정도 하고 있다
@EnableConfigurationProperties({WebMvcProperties.class})
어떤 값이 들어오는지는 해당클래스에 디버깅 걸면됨
ServletRegistrationBean 에서
서블릿 등록을 하고 잇다
다시 WebMvcAutoConfiguration 을 보면
public static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer, ServletContextAware
WebMvcConfigurer 인터페이스를 구현하고 있다
그리고 내부 클래스로 가장 핵심적인 설정을 하고 있는
EnableWebMvcConfiguration 가 있다
@EnableConfigurationProperties({WebProperties.class})
WebProperties 로 설정할 수 있게 돼있고
application.yml 에서 spring.web 으로 시작하면 된다
@ConfigurationProperties("spring.web")
public class WebProperties {
그리고 DelegatingWebMvcConfiguration 을 상속받고 있고 또 다시 WebMvcConfigurationSupport 를 상속받고 있다
WebMvcConfigurationSupport 이 클래스가 Spring web mvc 환경에서 가장 중요한 빈들을 등록하고 있다