我有以下控制器:
@Controller
public class ConfigController {
@GetMapping("/")
public String index() {
return "config";
}
}
然而,我在前往/
路線時(shí)收到以下錯(cuò)誤:
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template [config], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [config], template might not exist or might not be accessible by any of the configured Template Resolvers
我在resources/templates
中有一個(gè)config.html
文件:
My pom.xml file: https://pastebin.com/yqYYuXWh
我做錯(cuò)了什么?
我已經(jīng)嘗試在控制器函數(shù)的返回中添加一個(gè).html
,但它仍然不起作用。
在刪除spring-web依賴項(xiàng)(我已經(jīng)有了spring-boot-starter-web
)之后,我現(xiàn)在在啟動(dòng)spring時(shí)出現(xiàn)以下錯(cuò)誤:
Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
問題在您的pom.xml文件中。
將此塊添加到
build
;您已經(jīng)重寫了
spring-boot-starter-parent
自己的resources
塊,并使其包含application.properties
而沒有其他內(nèi)容。從pom.xml中刪除它并刪除目標(biāo)目錄。