spring boot 扫描不到自定义Controller
报错的原因是找不到对应的映射路径,即Controller没有被扫描到 。
应该让启动类和Controller的包在同一级目录下
官方建议application.java放的位置:
总结:
使用springboot启动类配置扫描的两种注解配置方式:
1、@Controller
@EnableAutoConfiguration
@ComponentScan
2、@SpringBootApplication
@SpringBootApplication注解等价于@Configuration, @EnableAutoConfiguration and @ComponentScan