項目的pom.xml資源過濾配置以下html
<resources> <resource> <directory>src/main/resources</directory> <!-- src/main/resources下的指定資源放行 --> <includes> <include>**/*.properties</include> <include>**/*.yml</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources>
spring boot + thymeleaf今天在啓動時提示
WARN:Cannot find template location: classpath:/templates/ (please add some templates or check your Thymel]
而後運行頁面報錯
Error resolving template "pages", template might not exist or might not be accessible by any of the configured Template Resolversspring
這個警告你能夠選擇忽略,不會影響編譯,實在看不過去或者不想看到警告內容能夠按下面操做。解決方法:
在application.propertoes或yml配置文件中添加,app
spring.freemarker.checkTemplateLocation=falsespa
spring: freemarker: checkTemplateLocation: false
這個有點想不明白,明顯都提示模板沒找到了還忽略提示,有點奇葩code
改application.propertoes,加註釋,各類方法都沒問題,最後就是頁面渲染不出來。xml
歸根結底,仍是由於模板沒找,這時纔想起pom.xml中的資源過濾,把.html的文件類型給過濾掉了。加上就行了。htm
<resources> <resource> <directory>src/main/resources</directory> <!-- src/main/resources下的指定資源放行 --> <includes> <include>**/*.properties</include> <include>**/*.yml</include> <include>**/*.xml</include> <include>**/*.html</include> </includes> <filtering>false</filtering> </resource> </resources>