在Spring Boot中,与Spring和Spring MVC相比,哪些注解是spring boot独有的。
时间: 2024-06-07 20:08:36 浏览: 18
在Spring Boot中,有一些注解是独有的,这些注解主要是用于简化配置和自动化配置,提高开发效率,以下是一些常见的Spring Boot独有注解:
1. `@SpringBootApplication`:用于标识一个Spring Boot应用,包含了`@Configuration`、`@EnableAutoConfiguration`和`@ComponentScan`三个注解的功能。
2. `@RestController`:用于标识一个控制器类,表示这是一个RESTful风格的控制器,简化了常规的`@Controller`和`@ResponseBody`的组合。
3. `@GetMapping`、`@PostMapping`、`@PutMapping`、`@DeleteMapping`等:用于标识一个HTTP请求处理方法,简化了常规的`@RequestMapping`注解。
4. `@ConfigurationProperties`:用于将配置文件中的属性值映射到Java Bean属性中,简化了常规的`@Value`注解。
5. `@EnableConfigurationProperties`:用于启用`@ConfigurationProperties`注解的自动配置。
6. `@EnableAsync`:用于启用Spring Boot的异步处理功能。
7. `@EnableScheduling`:用于启用Spring Boot的定时任务功能。
8. `@ConditionalOnProperty`、`@ConditionalOnBean`等:用于根据条件来控制自动配置的启用。
9. `@SpringBootTest`:用于在测试环境中启动Spring Boot应用,简化了常规的`@ContextConfiguration`注解。
需要注意的是,这些注解大多数都是基于Spring框架的注解进行的封装,因此如果熟悉Spring框架的话,使用起来会更加得心应手。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)