我在春天啓動的應用程序下面的項目結構,其中我想用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