0

Current I have 1 bug when I run 1 project of Spring 1- Create class common: BlogMvcApplication.java

    package blog;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

    @SpringBootApplication
    public class BlogMvcApplication {
        public static void main(String[] args) {
            SpringApplication.run(BlogMvcApplication.class, args);
        }
    }

2- Create class control: HomeController.java

package blog.controllers;

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

@Controller
public class HomeController {
@RequestMapping("/")
    public String index() {
        return "index";
    }
}

3- view: index.html

    <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8" />
    <title>Blog</title>
</head>

<body>
<h1>Welcome to Spring MVC</h1>
    Now is: <b th:text="${execInfo.now.time}"></b>
</body>

</html>

Error when access http://localhost:8080 is :

2017-03-02 00:55:41.931 ERROR 1068 --- [nio-8080-exec-1] org.thymeleaf.TemplateEngine             : [THYMELEAF][http-nio-8080-exec-1] Exception processing template "index": Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers

2017-03-02 00:55:41.958 ERROR 1068 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause

org.thymeleaf.exceptions.TemplateInputException: Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers at org.thymeleaf.TemplateRepository.getTemplate(TemplateRepository.java:246) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1104) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011) ~[thymeleaf-2.1.5.RELEASE.jar:2.1.5.RELEASE]

I think error because duplicate port 8080 when start Please helpme fix bug this Thanks!

  • Possible duplicate of [Error resolving template "index", template might not exist or might not be accessible by any of the configured Template Resolvers](http://stackoverflow.com/questions/31944355/error-resolving-template-index-template-might-not-exist-or-might-not-be-acces) – James Jithin Mar 01 '17 at 18:21
  • 1
    index.html should be inside `src/main/resources/templates`. – Murillo Goulart Mar 01 '17 at 18:22

1 Answers1

0

I don't think this error cause by duplication on port. If it is the issue then you cannot start your application and will see message like this: ".... port 8080 failed to start".

It seen like your index.html cannot be found at default location:/src/main/resources/templates/index.html when thymeleaf engine try to parse your requested template.

Hope it helps.

Duy Tran
  • 100
  • 5