我在春天启动的应用程序下面的项目结构,其中我想用ThymeleafThymeleaf不能检测弹簧引导工程模板内
projectName
-Gradle-Module1(Spring boot module)
-build
-src
-main
-resources
-templates
index.html
build.gradle
-Gradle-Module2
...
build.gradle
...
但弹簧引导找不到我的模板目录下,显示警告
Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
PS:我使用@EnableAutoConfiguration
在我的控制器代码,我做这样的事情
@Controller
@EnableAutoConfiguration
public class BaseController {
@RequestMapping(value = "/")
public String index() {
return "index.html";
}
}
和index.html
文件只是打印你好世界。
所以通常它应该看src/resources/templates/
(我想是相同的Gradle模块),但不知何故它无法找到它。
,当我尝试访问localhost:8080
我得到以下错误Error resolving template "index.html", template might not exist or might not be accessible by any of the configured Template Resolvers
有什么我失踪?
任何指针赞赏。
谢谢。
这是一个很好的问题。感谢问! – devdanke