Search code examples
spring-bootthymeleafapplication.properties

Changing default location of my Spring Boot template throws 404


When I have my index.html at the default location(/resource/templates/index.htm). Everything works fine. But when I Try to change the default location, It simply throws 404. Even after changing the application.properties .

Project Structure

enter image description here

Application.properties

server.port = 5000
spring.thymeleaf.cache = false
spring.thymeleaf.prefix = classpath:/Frontend/public/

Controller

    package iit.kent.cle;

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

@Controller
public class RouteController {

    @RequestMapping("/[^api]")
    public String index() {
        return "index" ;
    }

}

Solution

  • Should update the prefix on root of your application.properties, the root is in resources so the classpath starts on this:

    spring.thymeleaf.prefix = classpath:/templates/Frontend/public/