首页 > 编程语言 > 详细

SpringBoot的Web配置

时间:2018-04-01 11:08:14      阅读:212      评论:0      收藏:0      [点我收藏+]

 

重写全局配置

  • 如果springboot提供的springmvc配置不符合要求,则可以通过一个配置类(标有@Configuration注解的类)加上@EnableWebMvc注解来实现完全自己控制的mvc配置
  • 当你既想保留springboot提供的配置,又想增加自己额外的配置时,可以定义一个配置类并继承WebMvcConfigurationAdapter,无须使用@EnableWebMvc注解

servlet容器配置(servlet容器配置)

  • 如果需要使用代码的方式配置servlet容器,则可以注册一个实现EmbeddedServletContainerCustomizer接口的bean,若想直接配置Tomcat、Jetty、Undertow则可以直接定义TomcatEmbededServletContainerFactory、Jetty....、Undertow...
  • springboot默认是以tomcat作为servlet容器,修改为其他web容器
    <dependency>
          <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-web</artifactId>
              <exclusions>
                   <exclusion>
                       <groupId>org.springframework.boot</groupId>
                       <artifactId>spring-boot-starter-tomcat</artifactId>
                   </exclusion>
              </exclusions>
              <version>1.3.7.RELEASE</version>
    </dependency>
    <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>

     

     

SpringBoot的Web配置

原文:https://www.cnblogs.com/xhy-shine/p/8685914.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!