springboot的注解@SpringBootApplication

@SpringBootApplication 是一个组合注解

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = { @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class),
		@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) })
public @interface SpringBootApplication {

@SpringBootConfiguration 相当于 对@Configuration的封装 作用是将当前类标志位一个配置类

@EnableAutoConfiguration

这是一个开启自动装配的注解(同样为一个组合注解)

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {

@AutoConfigurationPackage  作用是将主程序类下的所有组件都扫描到Spring容器中 

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Import(AutoConfigurationPackages.Registrar.class)
public @interface AutoConfigurationPackage {
@Import(AutoConfigurationPackages.Registrar.class) 作用是导入AutoConfigurationPackages Registrar这个组件 Registrar组件的registerBeanDefinitions方法会得到@SpringBootApplication注解标注的类所在的包

 

@Import(AutoConfigurationImportSelector.class)作用 引入AutoConfigurationImportSelector组件 这个类是ImportSelector接口的实现,其中的selectImports方法为其核心方法 加载配置文件META-INF/spring.factories,从其中加载所有可能用到的配置类

 

这些注解解释了springboot 如何实现自动装配和自动扫描bean到容器的作用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
@DateTimeFormat是Spring Boot中的注解,用于将字符串转换成Date类型。它通常在前台向后台传递值时使用。通过在属性上添加@DateTimeFormat注解,并指定日期格式,可以自动将前台传递的字符串封装成Date类型的对象。 该注解在前台向后台传递值时起作用,而@JsonFormat注解则在后台向前台传递值时起作用。@JsonFormat注解将Date类型转换成字符串,一般在后台将值传递给前台时使用。通过在属性上添加@JsonFormat注解,并指定日期格式和时区,可以自动将Date类型的对象转换成字符串。 需要注意的是,@JsonFormat注解不仅可以完成后台到前台参数传递的类型转换,还可以实现前台到后台类型转换。当content-type为application/json时,优先使用@JsonFormat的pattern进行类型转换,而不会使用@DateTimeFormat进行类型转换。@JsonFormat注解的作用是完成json字符串到java对象的转换工作,与参数传递的方向无关。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [springBoot注解之@JsonFormat和@DateTimeFormat的作用](https://blog.csdn.net/weixin_43825761/article/details/127286337)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值