
Spring Boot整合Spring MVC
在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来添加我们的自定义配置。
👁️ 阅读量:0
© 版权声明:本文《Spring Boot整合Spring MVC》内容均为本站精心整理或网友自愿分享,如需转载请注明原文出处:https://www.zastudy.cn/wen/1686614416a305823.html。