Common forms of springboot2. X boot class location

1 when the startup class and controller are in the same class, add the annotation @controller in the class
2 when the startup class and controller are separated, the startup class should be placed in the root directory of the project, add the annotation @springbootapplication in the startup class,
2 when the startup class and controller are separated, the startup class should be placed in the root directory of the project, and add the annotation @componentscan in the startup class, And configure the package name to be scanned (basePackages=)
the second option is generally recommended
The project structure

startup class DemoProjectApplication


Read More: