SpringBoot基础

96 阅读1分钟
  1. 常见注解
  • @SpringBootApplication:SpringBootconfiguration配置类、ComponentScan扫描包、EnableAutoConfiguration导入其他配置类
  • @RestController:@ResponseBody和@Controller的作用
  • @Component @Service @Controller @Repository 将类注入容器
  • @GetMapping @PostMapping @PutMapping @DeleteMapping 映射请求,只能接收的对应的请求
  • @Autowired 按照类型注入
  • @Qualifier 和AutoWired联合使用,在按照类型匹配的基础上,再按照名称匹配
  • @Resource 按照名称匹配依赖注入
  • @Bean 用于将方法返回值对象放入容器
  • @RequestParam 获取查询参数
  • @RequestBody 获取请求体数据
  • @Value 将外部的值动态注入到Bean中