Common reasons
Package structure
- Make sure that your main class is in a root package above other classes.
- When you run a Spring Boot Application, (i.e. a class annotated with @SpringBootApplication), Spring will only scan the classes below your main class package.
Response body for @Controller
If you are using @Controller
over the Controller class then it will be treated as a MVC controller class. But if you want a special controller used in RESTFul web services then you to use @Controller
along with @ResponseBody
annotation or you can directly use @RestController
over the Controller
class.
Wring location of HTML when using @Controller
If you are using @Controller
to return a String
view name (for ex: index.html
) then ensure that the html file is within Resources/static