1.
2.
3.
4.
##5. 6. Another way is to start the service class and add @ComponentScan(basePackages={"xxx.xxx.xx", "xxx.xxx.xx"}) which contains the package Fully qualified name, can be multiple SpringBoot The custom controller cannot be scanned to SpringBoot. The custom controller route cannot be found because the startup class and the custom Controller package are not in the same directory. Down. Officially recommended location for application.java: Place other beans in the same package path as application.java, but this is not recommended. Solution: 1. Place the self-built controller class in the same directory as the startup class (this is not recommended). 2. Change the @RestController @EnableAutoConfiguration annotation of the startup class to @SpringBootApplication. 3. Start the class @RestController @EnableAutoConfiguration annotation plus @ComponentScan annotation.Two annotation configuration methods using springboot scanning:
1, the first@Controller @EnableAutoConfiguration @ComponentScan
@SpringBootApplication @ComponentScan
The above is the detailed content of How to solve the problem that SpringBoot cannot scan the Controller. For more information, please follow other related articles on the PHP Chinese website!