Adding spring-boot-starter-thymeleaf dependency solved the problem.
So add this to your pom.xml file:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Update: If you are working with Eclipse and you are using Gradle, this might not work. The reason is if you haven’t imported the project as ‘gradle project’ Eclipse wont detect thymeleaf. So here’s the solution:
Step1 : Run “gradle eclipse” on command line.
Step2 : Run “gradle wrapper”
Step3 : In eclipse import as gradle project (before this remove the already imported project)
Step4 : Now run using eclipse
Step5 : Enjoy!