企业网站建设招标p2p网站建设要多少钱
Spring、SpringMVC、Spring Boot常见注解
一、Spring
| 注解 | 说明 |
|---|---|
| @Component、@Controller、@Service、@Repository | 使用在类上用于实例化Bean |
| @Autowired | 使用在字段上用于根据类型依赖注入 |
| @Qualifier | 结合@Autowired一起使用用于根据名称进行依赖注入 |
| @Scope | 标注Bean的作用范围 |
| @Configuration | 指定当前类是一个Spring的配置类,当创建容器时会从该类上加载注解 |
| @ComponentScan | 用于指定Spring在初始化容器时要扫描的包 |
| @Bean | 使用在方法上,标注将该方法的返回值存储到Spring容器中 |
| @Import | 使用该注解导入的类会被Spring加载到容器中 |
| @Aspect、@Before、@Around、@After、@PointCut | 用于切面编程(AOP) |
二、SpringMVC
| 注解 | 说明 |
|---|---|
| @RequestMapping | 用于映射请求路径,可以定义在方法上。用于类上,则表示类中的所有方法都是以该地址作为父路径 |
| @RequestBody | 实现接收http请求的json数据,将json转换为java对象 |
| @RequestParam | 指定请求参数的名称 |
| @PathVariable | 用于获取请求路径参数 |
| @ResponseBody | 实现将controller方法返回对象转化为json对象返回给客户端 |
| @RequestHeader | 获取指定的请求头数据 |
| @RestController | @Controller + @ResponseBody |
三、Spring Boot
| 注解 | 说明 |
|---|---|
| @SpringBootConfiguration | 组合@Configuration注解,实现配置文件的功能 |
| @EnableAutoConfiguration | 打开自动配置功能,也可以关闭某个自动配置的选项 |
| @ComponentScan | Spring组件扫描 |
