Spring運行報警告Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)


原因:

SpringBoot會自動從/src/main/resources/templates目錄獲取Thymeleaf模板引擎,若該目錄缺失,就會報該警告。

 

方法1:

創建該目錄

 

方法2:

在application.yml中加入以下配置:

  thymeleaf:
    check-template: false
    check-template-location: false

如果是application.properties,就是加入

spring.thymeleaf.check-template=false
spring.thymeleaf.check-template-location=false

 

方法3:

去掉pom.xml中的以下配置:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM