在Spring Boot工程中,只需要在pom.xml中配置

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

既可以在启动的时候开启web模块,里面会启动了一个内嵌的tomcat服务器,自动配置的DispathServlet及相关的Spring MVC配置类。

自定义SpringMVC的配置

在Spring boot工程中,不需要再次在配置中指定<mvc:annotation-driven />或者是配置类中添加@EnableWebMVC,因为这样配置会让spring boot不再装配Spring MVC相关的配置,又回到了自己配置SpringMVC的传统老路,体现不了采用SpringBoot的好处。
我们可以继承WebMvcConfigurerAdapter来添加我们的自定义配置。

更多推荐

Spring Boot整合Spring MVC