Search code examples
javaspring-bootmodel-view-controller

Spring Boot Not Recognizing MVC Controller


I am creating a Spring Boot application with Spring Boot 3.3.0. I have placed my entities in a package called entities under the primary application package, and the controller is located in a package called controllers inside the main application package.

project structure

When I attempt to access any of the controller endpoints, I get a 404 error; For example when hitting localhost:8080/account-types/create the error returned is "There was an unexpected error (type=Not Found, status=404). No static resource account-types/account_type_create."

Templates: HTML templates

Controller Method: controller method


Solution

  • Everything is right in your code. It will work if you add thymeleaf dependency. For gradle it is

        implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
    

    For maven

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>