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";
}
}
项目结构:
运行效果:
一般不需要componentscan呢,你这样的话都扫描不到controller,改成使用mapperscan呢