场景:
在spring boot程序中,在启动类里有时候会在@SpringBootApplication注解添加scanBasePackages = {“com.xxx.xxx”}和@MapperScan注解之后,在网页或者postman中做请求的时候会显示404错误。
原因:
@SpringBootApplication(scanBasePackages = {“com.xxx.xxx”})注解会导致 Controller 层无法扫描到
解决:
在@SpringBootApplication(scanBasePackages = {“com.xxx.xxx”})中添加 Controller 层的路径 或者 本项目的路径进去即可。目的是让其能够扫描到 Controller 层。
结束:
欢迎点赞评论哦。
解决:@SpringBootApplication注解添加scanBasePackages之后请求报404错误
最新推荐文章于 2024-03-02 21:47:16 发布