<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></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jetty</artifactId></dependency>
源码分析
使用thymeleaf模板引擎需要添加的依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>
application.yml全局配置文件关于thymeleaf的配置
thymeleaf:cache:falsesuffix: .htmlprefix: classpath:/templates/mode: HTML5encoding: utf-8servlet:content-type: text/html
使用jsp模板引擎需要添加的依赖
<!--添加tomcat依赖模块.-少了很多东西--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId><scope>provided</scope></dependency><!--jsp本质就是个servlet - 内置tomcat没有该接口--><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><scope>provided</scope></dependency><!-- 添加jstl标签库依赖模块 --><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId></dependency><!-- 使用jsp引擎,springboot内置tomcat没有此依赖 - 解析jsp文件 --><dependency><groupId>org.apache.tomcat.embed</groupId><artifactId>tomcat-embed-jasper</artifactId><scope>provided</scope></dependency>
application.yml全局配置文件关于jsp的配置
spring:mvc:view:prefix: /WEB-INF/jsp/suffix: .jsp
WebMvcAutoConfiguration - 源码分析、调式
application.yml全局配置文件设置静态资源的访问路径
mvc:static-path-pattern: /resources/**resources:static-locations: classpath:/resources/
SpringMVC.xml的配置 - 等价与上面的配置
<Resourcesmapping=”/static/**”location=”/static/”/><!-- Mapping 等价于 staticPathPattern --><!-- Location 等价于 staticLocations -->
application.yml
spring:# 数据源的配置datasource:username: rootpassword:123456url: jdbc:mysql://localhost:3306/test?serverTimezone=UTCdriver-class-name: com.mysql.cj.jdbc.Driver# 模板引擎的相关配置thymeleaf:cache:falsesuffix: .htmlprefix: classpath:/templates/mode: HTMLencoding: utf-8servlet:content-type: text/html# 静态资源的路径mvc:static-path-pattern: /resources/**resources:static-locations: classpath:/resources/# 文件的上传与下载配置servlet:multipart:max-file-size: 50MBmax-request-size: 50MB# Tomcat服务器相关配置server:port:8080servlet:context-path: /springboot# mybatis的相关配置mybatis:configuration:cache-enabled:truetype-aliases-package: top.linruchang.springbootdemo.domainmapper-locations: classpath:/mapper/*Mapper.xmllazy-initialization:true