springspring-bootspring-mvcthymeleaf

Spring - Cannot resolve MVC "view" thymeleaf


I got a simple HomeController.class:

package com.example.tacos;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class HomeController {

    @GetMapping("/")
    public String home() {
        return "home";
    }
}

Also I got a template called home.html

<!DOCTYPE HTML>
    <head>
    <title>Getting Started: Serving Web Content</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>
    <body>
        <p>Hey</p>
    </body>
</html>

Anyway I'm getting 404 in the browser and IDE's telling me Cannot resolve MVC "view" as you can see on the screen

Folder Structure: Folder Structure

Browser: Browser


Solution

  • Hi I had the same issue and I fixed it by delete the version of Thymeleaf so the pom file will be like :

     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>