<dependency><groupId>org.springframework.bootgroupId><artifactId>spring-boot-starter-webartifactId><exclusions><exclusion><groupId>org.springframework.bootgroupId><artifactId>spring-boot-starter-tomcatartifactId>exclusion>exclusions>dependency><dependency><groupId>org.springframework.bootgroupId><artifactId>spring-boot-starter-jettyartifactId>dependency>
源码分析
使用thymeleaf模板引擎需要添加的依赖
<dependency><groupId>org.springframework.bootgroupId><artifactId>spring-boot-starter-thymeleafartifactId>dependency>
application.yml全局配置文件关于thymeleaf的配置
thymeleaf:cache:falsesuffix: .htmlprefix: classpath:/templates/mode: HTML5encoding: utf-8servlet:content-type: text/html
使用jsp模板引擎需要添加的依赖
<dependency><groupId>org.springframework.bootgroupId><artifactId>spring-boot-starter-tomcatartifactId><scope>providedscope>dependency><dependency><groupId>javax.servletgroupId><artifactId>javax.servlet-apiartifactId><scope>providedscope>dependency><dependency><groupId>javax.servletgroupId><artifactId>jstlartifactId>dependency><dependency><groupId>org.apache.tomcat.embedgroupId><artifactId>tomcat-embed-jasperartifactId><scope>providedscope>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/”/>
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