初学Springboot,根据教程在idea上新建项目并启动,浏览器访问报404错误,访问路径没有问题,注解也没有使用错误,问题就出在包路径,Spring Boot默认是扫描@SpringBootApplication注解的类的同包以及子包下的类,所以解决这个问题,可以加上@ComponentScan注解,或者修改Controller的包名,比如DemoApplication所在的包名为com.xxx.demo,那么controller的包名就为com.xxx.demo.controller
使用idea新建springboot项目浏览器访问404
最新推荐文章于 2024-02-02 15:30:32 发布