a simple spring boot application does not work

This can be the problem with packages of classes.

Make sure your ControllerClass is in the subpackage of DemoApplication (for example, DemoApplication is in org.example package and controller is in org.example.controllers package) or use @SpringBootApplication(scanBasePackages = "package.with.your.controller")

The problem is, the @SpringBootApplication annotation consists of:

@Configuration
@EnableAutoConfiguration
@ComponentScan

@ComponentScan here is without arguments, so according to docs, scanning will occur from the package of the class that declares this annotation. It will scan com.example.practice and subpackages, but not com.example.controllers.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top