Spring Boot 的核心注解

@SpringBootApplication

是 SpringBoot 的启动类。 此注解等同于@Configuration+@EnableAutoConfiguration+@ComponentScan 的组合。

@SpringBootConfiguration

@SpringBootConfiguration 注解是@Configuration 注解的派生注解,跟@Configuration 注解的功能一致,标注这个类是一个配置类,只不过@SpringBootConfiguration 是 springboot 的注解,而@Configuration 是 spring 的注解

@Configuration

通过对 bean 对象的操作替代 spring 中 xml 文件

@EnableAutoConfiguration

Spring Boot 自动配置(auto-configuration):尝试根据你添加的 jar 依赖自动配置你的 Spring 应用。是@AutoConfigurationPackage 和@Import(AutoConfigurationImportSelector.class) 注解的组合。

@AutoConfigurationPackage

@AutoConfigurationPackage 注解,自动注入主类下所在包下所有的加了注解的类 (@Controller,@Service 等),以及配置类(@Configuration)

@Import({AutoConfigurationImportSelector.class})

直接导入普通的类
导入实现了 ImportSelector 接口的类
导入实现了 ImportBeanDefinitionRegistrar 接口的类

@ComponentScan

组件扫描,可自动发现和装配一些 Bean。

@ConfigurationPropertiesScan

@ConfigurationPropertiesScan 扫描配置属性。@EnableConfigurationProperties 注解的作 用是使用 @ConfigurationProperties 注解的类生效。

@RestController

@RestController 相当于@Controller+@ResponseBody 注解 如果使用@RestController 注解 Controller 中的方法无法返回页面,相当于在方法上面自 动 加 了 @ResponseBody 注 解 , 所 以 没 办 法 跳 转 并 传 输 数 据 到 另 一 个 页 面 , 所 以 InternalResourceViewResolver 也不起作用,返回的内容就是 Return 里的内容。

@GetMapping

@GetMapping 注解是@RequestMapping(method = RequestMethod.GET)的缩写。

@PostMapping

@PostMapping 注解是@RequestMapping(method = RequestMethod.POST)的缩写。

@PutMapping

@PutMapping 注解是@RequestMapping(method = RequestMethod.PUT)的缩写。

@DeleteMapping

@DeleteMapping 注解是@RequestMapping(method = RequestMethod.DELETE)的缩写。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值