I'm developing a simple Spring Boot app that uses Spring Boot Web. I placed my index.html into the templates subdirectory of the resources directory as per the Spring Boot docs. I've defined inside the application.properties file:
spring.mvc.view.prefix=classpath:/templates/
spring.mvc.view.suffix=.html
My WebMvcConfigurerAdapter looks like this:
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter{
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("index");
super.addViewControllers(registry);
}
}
My problem is I cant seem to serve index.html at http://localhost:8080. I get the following error: "javax.servlet.ServletException: Could not resolve view with name 'index' in servlet with name 'dispatcherServlet'".
How can I fix this without the use of a controller?
Kind regards, Dave