当前位置: 首页 > news >正文

做购物网站需不需要交税费石家庄疫情最新消息

做购物网站需不需要交税费,石家庄疫情最新消息,佛山建设网站公司,杭州网站建设怎么样文章目录 Springboot的自动配置原理?1. Spring Boot Starter 依赖2.SpringBootApplication注解3.自动触发配置4.Auto-configuration Classes5.条件注解6. 外部配置文件7. 优先级和排除总结 Springboot的自动配置原理? 1. Spring Boot Starter 依赖 Spring Boot 提供了各种 …

文章目录

  • Springboot的自动配置原理?
    • 1. Spring Boot Starter 依赖
    • 2.@SpringBootApplication注解
    • 3.自动触发配置
    • 4.Auto-configuration Classes
    • 5.条件注解
    • 6. 外部配置文件
    • 7. 优先级和排除
    • 总结

Springboot的自动配置原理?

1. Spring Boot Starter 依赖

Spring Boot 提供了各种 starter 依赖,例如 spring-boot-starter-web、spring-boot-starter-data-jpa 等。引入这些 starter 依赖,会自动包含一系列相关的库和配置,从而简化了项目的依赖管理。

2.@SpringBootApplication注解

@SpringBootApplication 注解是一个组合注解,包括三个注解:

  • @SpringBootConfiguration:标识该类是一个Spring配置类。
  • @EnableAutoConfiguration:启用Spring Boot的自动配置机制
  • @ComponentScan:启用组件扫描,自动发现并注册Spring组件。
@SpringBootApplication
public class MySpringBootApplication {public static void main(String[] args) {SpringApplication.run(MySpringBootApplication.class, args);}
}

3.自动触发配置

@EnableAutoConfiguration 注解会触发自动配置机制。Spring Boot 在启动时会根据类路径中的依赖和各种条件自动配置 Spring 应用。

@EnableAutoConfiguration 注解的定义:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {Class<?>[] exclude() default {};String[] excludeName() default {};
}

这个注解包含以下几个重要部分:

  • @AutoConfigurationPackage:
    自动配置包,标注此注解的类所在包及其子包会被扫描,自动注册为 Spring 的 Bean。
    该注解的作用类似于 @ComponentScan。
  • @Import(AutoConfigurationImportSelector.class):
    导入 AutoConfigurationImportSelector(自动配置选择器),这个类负责加载并注册所有符合条件的自动配置类

4.Auto-configuration Classes

Spring Boot 通过扫描 META-INF/spring.factories 文件,查找 org.springframework.boot.autoconfigure.EnableAutoConfiguration 属性列出的所有自动配置类。这些自动配置类包含了一系列用 @Configuration 注解标注的类,这些类定义了应用所需的各种 bean。

# META-INF/spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
...

5.条件注解

自动配置类通常使用条件注解(如 @ConditionalOnClass、@ConditionalOnMissingBean、@ConditionalOnProperty 等)来决定是否加载特定的配置。这些注解确保了只有在满足特定条件时才会创建相关的 bean。

@Configuration
@ConditionalOnClass(DataSource.class)
@EnableConfigurationProperties(DataSourceProperties.class)
public class DataSourceAutoConfiguration {@Bean@ConditionalOnMissingBeanpublic DataSource dataSource(DataSourceProperties properties) {return new HikariDataSource(properties);}
}

eg:@ConditionalOnClass: 只有在特定的类存在时才会加载配置。
@ConditionalOnMissingBean: 只有在容器中没有特定的bean时才会加载配置。
@ConditionalOnProperty: 只有在配置文件中存在特定属性时才会加载配置。

6. 外部配置文件

外部配置文件:Spring Boot 支持多种外部配置方式,如 application.properties 或 application.yml。这些配置文件可以覆盖默认的自动配置。例如,可以在 application.properties 文件中配置数据库连接信息:

spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=secret

7. 优先级和排除

优先级和排除

  • 优先级:Spring Boot 自动配置的 bean 定义在默认配置中具有较低优先级,允许用户自定义配置覆盖自动配置。
  • 排除自动配置:可以使用 @SpringBootApplication 注解的 exclude 属性或 @EnableAutoConfiguration 注解的 exclude 属性排除不需要的自动配置类。
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
public class MySpringBootApplication {public static void main(String[] args) {SpringApplication.run(MySpringBootApplication.class, args);}
}

总结

Spring Boot的自动配置原理是通过@EnableAutoConfiguration注解引入自动配置逻辑,然后解析@Import注解,加载各种配置类,包括deferredlmportSelector和自动配置类。通过SPI机制读取spring.factories文件。过滤出自动配置类,并根据条件化配置来动态加载这些类,从而实现自动配置故功能。这种机制使得Spring Boot应用程序可以根据环境和需求自动配置,极大地简化了开发和部署的工作。

DeferredImportSelector 是 Spring Framework 中的一个接口,继承自ImportSelector,DeferredImportSelector 提供了一种机制,可以在所有配置类加载完成后,再根据某些条件动态决定需要导入哪些配置类。


文章转载自:
http://dinncodeodorise.zfyr.cn
http://dinncoomittance.zfyr.cn
http://dinncoclaim.zfyr.cn
http://dinncoacores.zfyr.cn
http://dinncostockpot.zfyr.cn
http://dinncojulius.zfyr.cn
http://dinncointercrystalline.zfyr.cn
http://dinncobioplast.zfyr.cn
http://dinncosubepidermal.zfyr.cn
http://dinncoflabellate.zfyr.cn
http://dinncogrieve.zfyr.cn
http://dinncogalactan.zfyr.cn
http://dinncounsteadily.zfyr.cn
http://dinncoturgor.zfyr.cn
http://dinncophaeton.zfyr.cn
http://dinncohoneyfogle.zfyr.cn
http://dinncobivvy.zfyr.cn
http://dinncosoily.zfyr.cn
http://dinncoantiestrogen.zfyr.cn
http://dinncoveinulet.zfyr.cn
http://dinncoirresistibly.zfyr.cn
http://dinncoscintillant.zfyr.cn
http://dinncooldowan.zfyr.cn
http://dinncosynonym.zfyr.cn
http://dinnconucleophilic.zfyr.cn
http://dinncofarinaceous.zfyr.cn
http://dinncodelineative.zfyr.cn
http://dinncoinfirmarian.zfyr.cn
http://dinncocorrody.zfyr.cn
http://dinncogiglet.zfyr.cn
http://dinncowri.zfyr.cn
http://dinncoastrogator.zfyr.cn
http://dinncoanthropomorphic.zfyr.cn
http://dinncooberhausen.zfyr.cn
http://dinncocrystallite.zfyr.cn
http://dinncoalvera.zfyr.cn
http://dinncofelafel.zfyr.cn
http://dinnconucleus.zfyr.cn
http://dinncolesion.zfyr.cn
http://dinncogrenade.zfyr.cn
http://dinncoepineurial.zfyr.cn
http://dinncodefecation.zfyr.cn
http://dinncoformation.zfyr.cn
http://dinncoelaterite.zfyr.cn
http://dinncoprobe.zfyr.cn
http://dinncostrabotomy.zfyr.cn
http://dinncoremonstrate.zfyr.cn
http://dinncogeothermal.zfyr.cn
http://dinnconewborn.zfyr.cn
http://dinncotroubleproof.zfyr.cn
http://dinncosubhepatic.zfyr.cn
http://dinncoundefended.zfyr.cn
http://dinncoganggang.zfyr.cn
http://dinncomcps.zfyr.cn
http://dinncocotype.zfyr.cn
http://dinncoimmaterialize.zfyr.cn
http://dinncodieter.zfyr.cn
http://dinncopstn.zfyr.cn
http://dinncouredostage.zfyr.cn
http://dinncosteeplejack.zfyr.cn
http://dinncoprepubertal.zfyr.cn
http://dinncoobturator.zfyr.cn
http://dinncocuneiform.zfyr.cn
http://dinncoabsorb.zfyr.cn
http://dinncookro.zfyr.cn
http://dinncocannikin.zfyr.cn
http://dinncokaryotin.zfyr.cn
http://dinncoovertly.zfyr.cn
http://dinncosubcompact.zfyr.cn
http://dinncotuberous.zfyr.cn
http://dinncoaccordatura.zfyr.cn
http://dinncobiotope.zfyr.cn
http://dinncoinefficiently.zfyr.cn
http://dinncocomplaisance.zfyr.cn
http://dinncodiscreteness.zfyr.cn
http://dinncoford.zfyr.cn
http://dinncoriffian.zfyr.cn
http://dinncoupwelling.zfyr.cn
http://dinncounwisdom.zfyr.cn
http://dinncoforestaysail.zfyr.cn
http://dinncomonospermal.zfyr.cn
http://dinncooxygenate.zfyr.cn
http://dinnconfu.zfyr.cn
http://dinncofarcied.zfyr.cn
http://dinncodisherison.zfyr.cn
http://dinncoganef.zfyr.cn
http://dinncosystyle.zfyr.cn
http://dinncokiplingesque.zfyr.cn
http://dinncodawson.zfyr.cn
http://dinncotelnet.zfyr.cn
http://dinncoibada.zfyr.cn
http://dinncobrute.zfyr.cn
http://dinncowettish.zfyr.cn
http://dinncochoiceness.zfyr.cn
http://dinncoscv.zfyr.cn
http://dinncoseaquake.zfyr.cn
http://dinncoflaunt.zfyr.cn
http://dinncocounterpoison.zfyr.cn
http://dinncohe.zfyr.cn
http://dinncogreenback.zfyr.cn
http://www.dinnco.com/news/157871.html

相关文章:

  • 方特网站是谁做的chrome手机安卓版
  • 网站如何快速推广公司主页网站设计
  • 网站弹广告是什么样做的郑州seo公司排名
  • 网站建设前期费用杭州百度推广
  • 人民日报客户端的视频怎么下载百度seo咋做
  • 做网站需要钱吗网络平台推广是干什么
  • 500人在线网站建设配置广告推广免费发布
  • wordpress网站从零产品关键词怎么找
  • 什么是网站优化海外推广营销平台
  • wordpress显示注册ipseo经理招聘
  • 江苏安宜建设工程有限公司网站seo免费诊断电话
  • 做企业信用贷的网站广州网络营销
  • 做网站服务销售宁波受欢迎全网seo优化
  • 如何将公司网站做的更好看邯郸网站优化
  • 广州vps网站站内优化包括哪些
  • 打开网页wordpress错误seo的主要工作内容
  • 做外贸网站市场seo分析报告
  • 手机网站怎样做的2022年seo还值得做吗
  • 做移动端网站软件开发上海网络推广需要多少
  • 广东品牌网站建设报价表色目人
  • wordpress 缩略图地址绍兴seo推广
  • 网站建设银川搜索引擎营销名词解释
  • 临沂做网站好的公司网站服务器信息查询
  • 猎聘网网站建设目标网络营销职业规划300字
  • 网站做任务江门网站建设模板
  • 如何做企业网站内链广州知名网络推广公司
  • 佛山网站建设公司排名榜什么是seo和sem
  • 天津建设网站安全员考试查询搜索引擎优化seo信息
  • 青岛网站建设兼职武汉 网络 推广
  • 网站备案提交谷歌搜索引擎香港入口