我的代码是



问题解决了....
原来要在controller上配置三个注解
@Controller
@EnableAutoConfiguration
@ComponentScan(basePackages = {"controller"})
@Controller
@EnableAutoConfiguration
@ComponentScan
这个三个注解就相当于@SpringBootApplication
在你的spring boot启动类去掉@ComponentScan这个注解
这个不用的吧 application能扫描它同级和下级的包 你把application拉到包外面就行了吧