使用Spring boot 2.2时thymeleaf发生的问题
今天使用spring boot 2.2时发现无法访问templates下的页面,经检查代码,项目结构均无问题,通过上网搜索发现了pom.xml中版本号的问题,并解决,以下是解决方案:
未修改前的pom文件
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>
这里用的是org.springframework.boot下的spring-boot-starter-thymeleaf,使用<thymeleaf.version>做标签时可能与org.thymeleaf有冲突,导致包获取不正确
可以看到thymeleaf的版本号处代码为
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
这里可能与org.springframework.boot下的spring-boot-stater-thymleaf冲突,导致包不正确,导致项目出现错误
修改为:
<properties>
<java.version>1.8</java.version>
<springboot-thymeleaf.version>3.0.9.RELEASE</springboot-thymeleaf.version>
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
</properties>
修改后问题解决