SpringBoot使用Thymeleaf打成jar包部署找不到頁面
使用SpringBoot+Thymeleaf時,在IDEA中運行正常,但打成Jar包運行時,報錯:
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/wx/auth], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.11.RELEASE.jar:3.0.11.RELEASE]
解決方案:
- 1.確認模板文件是否在templates文件夾里
- 2.返回路徑"/wx/auth"這樣寫是不對的,要把斜杠去掉"wx/auth"