- 无法解析映射到指定的 thymeleaf 模板.
Spring Boot 默认依赖的是低版本的Thymeleaf,低版本的Thymeleaf不能解析HTML5格式的HTML代码,而是把HTML当成XML解析,所有标签必须闭合!
在pom.xml中的properties标签中加入如下代码
<!-- 覆盖thymeleaf版本依赖 -->
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-extras-java8time.version>3.0.0.RELEASE</thymeleaf-extras-java8time.version>
<thymeleaf-layout-dialect.version>2.0.5</thymeleaf-layout-dialect.version>
完美解决问题
- 创建SpringBoot工程最好使用模板,避免必要的依赖丢失导致工程无法启动。
SpringBoot的一个基本依赖为
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
</dependencies>
spring-boot-starter-web
:集成了Tomcat相关配置,Spring MVC,会自动配置一个web项目的逻辑(不要忘记,笔者踩过坑)
spring-boot-starter-tomcat
: 内嵌的 Tomcat
spring-boot-starter-thymeleaf
: SpringBoot默认的模板引擎
- windows下的logback路径引用问题
日志生成路径
这里不能使用windows路径的\
,会被自动忽略,必须使用unix的路径表示方法,属性值将会生成对应的工程所在盘符下的目录结构。
官网说明
官网也语焉不详,只是给出了 unix风格路径,使用时注意即可。
网友评论