Spring之常见注解

1、Spring常见注解

  • @Component、@Controller 、@Service 、@Repository    使用在类上用于实例化Bean
  • @Autowired    使用在字段上用于根据类型依赖注入
  • @Qualifier    结合@Autowired一起使用,用于根据名称进行依赖注入
  • @Scope    标注Bean的作用范围
  • @Configuration    指定当前类是一个Spring配置类,当创建容器时会从该类上加载注解
  • @ComponentScan    用于指定Spring在初始化容器时要扫描的包
  • @Bean    使用在方法上,标注将该方法的返回指存储到Spring容器中
  • @Import    使用@Import导入的类会被Spring加载到IOC容器中
  • @Aspect、@Before、@After、@Around、@Pointcut    用于切面编程(AOP)

2、SpringMVC常见注解

  • @RequestMapping        用于映射请求路径,可以定义在类上和方法上。用于类上,则表示类中的所有方法都以该地址作为父路径
  • @RequestBody        注解实现接收http请求的json数据,将json转换为Java对象
  • @RequstParam        指定请求参数的名称
  • @PathViriable        从请求路径中获取请求参数(/user/{id}),传递给方法的形式参数
  • @ResponseBody        注解实现将controller方法返回对象转化json对象响应给客户端
  • @RequestHeader        获取指定的请求头数据
  • @RestController        @Controller +@ResponseBody

3、Srping Boot常见注解

  • @SpringBootConfiguration 组合了-@Configuration,实现配置文件的功能
  • @EnableAutoConfiguration 打开自动配置的功能,也可以关闭某个自动配置功能
  • @ComponentScan        Spring组件扫描

相关推荐

  1. Spring常见注解

    2024-07-15 00:48:01       20 阅读
  2. Spring boot 常见注解

    2024-07-15 00:48:01       48 阅读
  3. Spring常见注解

    2024-07-15 00:48:01       28 阅读
  4. Spring注解开发

    2024-07-15 00:48:01       57 阅读
  5. spring注解——@Service

    2024-07-15 00:48:01       32 阅读
  6. Spring注解实现依赖注入

    2024-07-15 00:48:01       55 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-15 00:48:01       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-15 00:48:01       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-15 00:48:01       58 阅读
  4. Python语言-面向对象

    2024-07-15 00:48:01       69 阅读

热门阅读

  1. Golang 后端面经

    2024-07-15 00:48:01       21 阅读
  2. 印度标普基金关门,继续套利美元债LOF

    2024-07-15 00:48:01       20 阅读
  3. 基于深度学习的点云平滑

    2024-07-15 00:48:01       19 阅读
  4. 【网络编程】poll函数

    2024-07-15 00:48:01       18 阅读
  5. 19. 删除链表的倒数第 N 个结点

    2024-07-15 00:48:01       16 阅读
  6. PyMysql error : Packet Sequence Number Wrong - got 1 expected 0

    2024-07-15 00:48:01       20 阅读
  7. TCP和UDP知识点

    2024-07-15 00:48:01       21 阅读
  8. 【C++】指针学习 知识点总结+代码记录

    2024-07-15 00:48:01       19 阅读
  9. 游戏开发面试题1

    2024-07-15 00:48:01       17 阅读
  10. 利率债与信用债的区别及其与债券型基金的关系

    2024-07-15 00:48:01       19 阅读
  11. 域名信息的收集

    2024-07-15 00:48:01       19 阅读