thymeleaf在开发环境正常,但用jar运行时报错 Error resolving template templat

时间:2022-06-03 23:07:01

 

通过打包 jar直接运行的

百度搜索此关键词找到的:“springboot jar error resolving template”

 

原因是指向模板的路径前有斜杆/,就会出错,去掉就正常了(路径前不能带斜杆,类似相对路径的写法)

网上有人说增加配置spring.thymeleaf.prefix=classpath:/templates也能解决