springboot项目启动正常,但是访问controller的任意一个都报404错误

问题遇到的现象和发生背景

springboot项目启动正常,但是访问controller的任意一个都报404错误

用代码块功能插入代码,请勿粘贴截图
// 主程序
@SpringBootApplication
@ComponentScan(basePackages = "com.oli.blog_server.mapper")
public class BlogServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(BlogServerApplication.class, args);
    }
}
//controller层
@RestController
@Slf4j
public class HelloController {
    @RequestMapping("/")
    public String index(){
        return "index";
    }

    @GetMapping("/get")
    public String getMsg(){
        return "index";
    }
}
运行结果及报错内容

项目结构:

img


运行截图:

img

运行效果:

img

img

一般不需要componentscan呢,你这样的话都扫描不到controller,改成使用mapperscan呢