Reputation: 590
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
Upvotes: 8
Views: 24401
Reputation: 1400
I had all the dependencies and settings for IntelliJ. What I was missing was settings for Thymeleaf on the application.properties (or applications.yml):
application.properties
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
application.yml
spring:
thymeleaf:
prefix: classpath:/templates/
suffix: .html
Upvotes: 0
Reputation: 11
I just encountered the same problem, but I managed to resolve it.
I simply copied the following code snippet exists in pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
and modified artifactId
to spring-boot-starter-thymeleaf
,then, I faced the same problem.
In my case, I removed the scope element and reloaded the configuration. It seems to be working fine for now.
Upvotes: 0
Reputation: 1058
I previously added dependency
<!-- Thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>3.1.4</version>
</dependency>
It doesn't work, even if I reload the Maven project.
Then I added <version>3.1.4</version>
to reload again, it works!
Upvotes: 0
Reputation: 21
To anyone who use Gradle, I had this in my build.gradle file;
implementation 'org.thymeleaf:thymeleaf:3.1.2.RELEASE'
I have changed it to
implementation('org.springframework.boot:spring-boot-starter-thymeleaf:3.0.4')
and it worked for me.
Upvotes: 1
Reputation: 11
I found that my current project was created in another previous project.
Error was fixed after changing the project location.
Upvotes: 1
Reputation: 6440
I had the same issue in the project as:
"Cannot resolve MVC view"
and the cause of it was misspelling
with naming of the folder.
The structure was:
| |-- resources
| | |-- template
| | | |-- customer.html
| | | |-- customerForm.html
| | | |-- customers.html
| | | |-- index.html
I needed to use the name as templates
of the folder, but I had template
.
Maybe, it'd be helpful for someone also.
Upvotes: 2
Reputation: 301
To solve this problem you should add path to web app
package into Web Resource Directories.
Upvotes: 7
Reputation: 81
I had the correct entry suggested by gumira in my pom.xml and I was still getting the error.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
I had to fix Maven Plugin not found in IntelliJ IDE instead and rebuild.
Upvotes: 0
Reputation: 136
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>
Upvotes: 12
Reputation: 590
The problem was that in pom.xml I had this:
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
instead of this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
Just started learning spring and don`t get dependencies well enough yet:)
Upvotes: 2