springboot 2.0 Thymeleaf 找不到模板错误template might not exist or might not be accessible

网上的 项目原来是 springboot 1.5X项目,用springboot2.0X 搭建报错:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [login], template might not exist or might not be accessible by any of the configured Template Resolvers

各种修改:

以为是配置文件,或者thymeleaf 版本问题导致的

  1、配置文件

       

#spring.thymeleaf.prefix=classpath:/templates/  此配置经验证 可以不配 默认会找到这个包,前提是包名必须是 templates
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html 
spring.thymeleaf.cache=false

2、pom 文件

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
   <!--<version>3.0.9.RELEASE</version>-->  本身内置版本为<version>2.1.5.RELEASE</version>
</dependency>

最后发现问题 为被坑了:

<build>

   <resources>
      <resource>
         <directory>src/main/java</directory>
         <includes>
            <include>**/*.yml</include>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
         </includes>
         <filtering>false</filtering>
      </resource>

就是下面这段 把html 过滤掉了 去掉 添加 <include>**/*.html</include> 都可以
   <resource>
         <directory>src/main/resources</directory>
         <includes>
            <include>**/*.yml</include>
            <include>**/*.properties</include>
            <include>**/*.xml</include>
         </includes>
         <filtering>false</filtering>
      </resource>
   </resources>
   <plugins>
      <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
   </plugins>
</build>
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值