问题遇到的现象和发生背景
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";
}
}
运行结果及报错内容
项目结构:
运行截图:
运行效果: