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

wordpress如何自动采集网站图片深圳网站制作哪家好

wordpress如何自动采集网站图片,深圳网站制作哪家好,青海省住房城乡建设厅网站,java编程代码大全1 简介 1.1 什么是自动装配? 自动装配是指 Spring Boot 在启动时,根据类路径上的依赖项自动配置应用程序。例如,如果你的应用程序依赖于 Spring Data JPA,Spring Boot 会自动配置一个 DataSource、EntityManagerFactory 和其他必…

1 简介

1.1 什么是自动装配?

自动装配是指 Spring Boot 在启动时,根据类路径上的依赖项自动配置应用程序。例如,如果你的应用程序依赖于 Spring Data JPA,Spring Boot 会自动配置一个 DataSourceEntityManagerFactory 和其他必要的 Bean,而无需你手动编写这些配置。

1.2 自动装配的工作原理
  1. 依赖管理:Spring Boot 使用 Maven 或 Gradle 管理依赖项。当你在 pom.xml 或 build.gradle 文件中添加依赖项时,Spring Boot 会检测这些依赖项。

  2. 自动配置类:Spring Boot 提供了一组自动配置类,这些类位于 spring-boot-autoconfigure 模块中。每个自动配置类都对应一个特定的技术栈或功能模块。

  3. 条件注解:自动配置类使用条件注解(如 @ConditionalOnClass@ConditionalOnMissingBean 等)来决定是否应用某个配置。这些注解确保只有在满足特定条件时才会应用配置。

2 源码解读

入口:@SpringBootApplication

//以下是@SpringBootApplication注解的内部信息 其中最核心的是后3条
@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) })

2.1 @SpringBootConfiguration
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Indexed
//这个注解的主要主要表明这是一个配置类 需要解析
public @interface SpringBootConfiguration {/*** Specify whether {@link Bean @Bean} methods should get proxied in order to enforce* bean lifecycle behavior, e.g. to return shared singleton bean instances even in* case of direct {@code @Bean} method calls in user code. This feature requires* method interception, implemented through a runtime-generated CGLIB subclass which* comes with limitations such as the configuration class and its methods not being* allowed to declare {@code final}.* <p>* The default is {@code true}, allowing for 'inter-bean references' within the* configuration class as well as for external calls to this configuration's* {@code @Bean} methods, e.g. from another configuration class. If this is not needed* since each of this particular configuration's {@code @Bean} methods is* self-contained and designed as a plain factory method for container use, switch* this flag to {@code false} in order to avoid CGLIB subclass processing.* <p>* Turning off bean method interception effectively processes {@code @Bean} methods* individually like when declared on non-{@code @Configuration} classes, a.k.a.* "@Bean Lite Mode" (see {@link Bean @Bean's javadoc}). It is therefore behaviorally* equivalent to removing the {@code @Configuration} stereotype.* @return whether to proxy {@code @Bean} methods* @since 2.2*/@AliasFor(annotation = Configuration.class)boolean proxyBeanMethods() default true;}
2.2 @EnableAutoConfiguration
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
//自动注册一个basepackage的bean 作用是存储扫描路径 给其他组件使用
@AutoConfigurationPackage
//实现自动装配
@Import(AutoConfigurationImportSelector.class)
public @interface EnableAutoConfiguration {/*** Environment property that can be used to override when auto-configuration is* enabled.*/String ENABLED_OVERRIDE_PROPERTY = "spring.boot.enableautoconfiguration";/*** Exclude specific auto-configuration classes such that they will never be applied.* @return the classes to exclude*/Class<?>[] exclude() default {};/*** Exclude specific auto-configuration class names such that they will never be* applied.* @return the class names to exclude* @since 1.3.0*/String[] excludeName() default {};}

2.2.1 @AutoConfigurationPackage

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
//引入注册器注册basepackage的bean
@Import(AutoConfigurationPackages.Registrar.class)
public @interface AutoConfigurationPackage {/*** Base packages that should be registered with {@link AutoConfigurationPackages}.* <p>* Use {@link #basePackageClasses} for a type-safe alternative to String-based package* names.* @return the back package names* @since 2.3.0*/String[] basePackages() default {};/*** Type-safe alternative to {@link #basePackages} for specifying the packages to be* registered with {@link AutoConfigurationPackages}.* <p>* Consider creating a special no-op marker class or interface in each package that* serves no purpose other than being referenced by this attribute.* @return the base package classes* @since 2.3.0*/Class<?>[] basePackageClasses() default {};}static class Registrar implements ImportBeanDefinitionRegistrar, DeterminableImports {@Overridepublic void registerBeanDefinitions(AnnotationMetadata metadata, BeanDefinitionRegistry registry) {//注册basepackage的beanregister(registry, new PackageImports(metadata).getPackageNames().toArray(new String[0]));}@Overridepublic Set<Object> determineImports(AnnotationMetadata metadata) {return Collections.singleton(new PackageImports(metadata));}}
2.2.2 @Import(AutoConfigurationImportSelector.class)
//这个我们先看实现的接口
//1 实现了DeferredImportSelector 而DeferredImportSelector继承了ImportSelector 作用是用来注册bean
//2 DeferredImportSelector对ImportSelector进行了增强 只有其他配置类扫描完了后 再解析这个引入的bean 为了确保条件注解的正确性
//3 重写了DeferredImportSelector的getImportGroup方法 调用好 优先会调用getImportGroup方法
public class AutoConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware,ResourceLoaderAware, BeanFactoryAware, EnvironmentAware, Ordered {}public Class<? extends Group> getImportGroup() {//spring为注册分组的类 会自动调用该类的process方法return AutoConfigurationGroup.class;
}       public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) {Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector,() -> String.format("Only %s implementations are supported, got %s",AutoConfigurationImportSelector.class.getSimpleName(),deferredImportSelector.getClass().getName()));//获取自动配置类            AutoConfigurationEntry autoConfigurationEntry = ((AutoConfigurationImportSelector) deferredImportSelector).getAutoConfigurationEntry(annotationMetadata);this.autoConfigurationEntries.add(autoConfigurationEntry);for (String importClassName : autoConfigurationEntry.getConfigurations()) {this.entries.putIfAbsent(importClassName, annotationMetadata);}
}protected AutoConfigurationEntry getAutoConfigurationEntry(AnnotationMetadata annotationMetadata) {if (!isEnabled(annotationMetadata)) {return EMPTY_ENTRY;}//1 获取注解的属性AnnotationAttributes attributes = getAttributes(annotationMetadata);//2 扫描自动装配类List<String> configurations = getCandidateConfigurations(annotationMetadata, attributes);//3 去重configurations = removeDuplicates(configurations);//4 获取过滤的bean集Set<String> exclusions = getExclusions(annotationMetadata, attributes);checkExcludedClasses(configurations, exclusions);//5 移除过滤的beanconfigurations.removeAll(exclusions);configurations = getConfigurationClassFilter().filter(configurations);fireAutoConfigurationImportEvents(configurations, exclusions);return new AutoConfigurationEntry(configurations, exclusions);
}protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {//加载配置文件获取配置List<String> configurations = new ArrayList<>(SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader()));ImportCandidates.load(AutoConfiguration.class, getBeanClassLoader()).forEach(configurations::add);Assert.notEmpty(configurations,"No auto configuration classes found in META-INF/spring.factories nor in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. If you "+ "are using a custom packaging, make sure that file is correct.");return configurations;
}public static List<String> loadFactoryNames(Class<?> factoryType, @Nullable ClassLoader classLoader) {ClassLoader classLoaderToUse = classLoader;if (classLoader == null) {classLoaderToUse = SpringFactoriesLoader.class.getClassLoader();}String factoryTypeName = factoryType.getName();//加载配置文件获取配置return (List)loadSpringFactories(classLoaderToUse).getOrDefault(factoryTypeName, Collections.emptyList());
}private static Map<String, List<String>> loadSpringFactories(ClassLoader classLoader) {Map<String, List<String>> result = (Map)cache.get(classLoader);if (result != null) {return result;} else {Map<String, List<String>> result = new HashMap();try {//从META-INF/spring.factories获取所有的自动装配类Enumeration<URL> urls = classLoader.getResources("META-INF/spring.factories");while(urls.hasMoreElements()) {URL url = (URL)urls.nextElement();UrlResource resource = new UrlResource(url);Properties properties = PropertiesLoaderUtils.loadProperties(resource);Iterator var6 = properties.entrySet().iterator();while(var6.hasNext()) {Map.Entry<?, ?> entry = (Map.Entry)var6.next();String factoryTypeName = ((String)entry.getKey()).trim();String[] factoryImplementationNames = StringUtils.commaDelimitedListToStringArray((String)entry.getValue());String[] var10 = factoryImplementationNames;int var11 = factoryImplementationNames.length;for(int var12 = 0; var12 < var11; ++var12) {String factoryImplementationName = var10[var12];((List)result.computeIfAbsent(factoryTypeName, (key) -> {return new ArrayList();})).add(factoryImplementationName.trim());}}}result.replaceAll((factoryType, implementations) -> {return (List)implementations.stream().distinct().collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));});cache.put(classLoader, result);return result;} catch (IOException var14) {throw new IllegalArgumentException("Unable to load factories from location [META-INF/spring.factories]", var14);}}
}

2.3 @ComponentScan()

@Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class)public class TypeExcludeFilter implements TypeFilter, BeanFactoryAware {private BeanFactory beanFactory;private Collection<TypeExcludeFilter> delegates;@Overridepublic void setBeanFactory(BeanFactory beanFactory) throws BeansException {this.beanFactory = beanFactory;}@Overridepublic boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory)throws IOException {//去容器中获取所有类型为TypeExcludeFilter的bean 去执行过滤//我们可以实现这个方法 重写match方法 完成过滤if (this.beanFactory instanceof ListableBeanFactory && getClass() == TypeExcludeFilter.class) {for (TypeExcludeFilter delegate : getDelegates()) {if (delegate.match(metadataReader, metadataReaderFactory)) {return true;}}}return false;}private Collection<TypeExcludeFilter> getDelegates() {Collection<TypeExcludeFilter> delegates = this.delegates;if (delegates == null) {delegates = ((ListableBeanFactory) this.beanFactory).getBeansOfType(TypeExcludeFilter.class).values();this.delegates = delegates;}return delegates;}@Overridepublic boolean equals(Object obj) {throw new IllegalStateException("TypeExcludeFilter " + getClass() + " has not implemented equals");}@Overridepublic int hashCode() {throw new IllegalStateException("TypeExcludeFilter " + getClass() + " has not implemented hashCode");}}

@Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) public class AutoConfigurationExcludeFilter implements TypeFilter, BeanClassLoaderAware {private ClassLoader beanClassLoader;private volatile List<String> autoConfigurations;@Overridepublic void setBeanClassLoader(ClassLoader beanClassLoader) {this.beanClassLoader = beanClassLoader;}@Overridepublic boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory)throws IOException {//1 是否是一个配置类//2 是否有AutoConfiguration或者在自动装配类已配置//同时满足上面两个条件就不扫描这个beanreturn isConfiguration(metadataReader) && isAutoConfiguration(metadataReader);}private boolean isConfiguration(MetadataReader metadataReader) {return metadataReader.getAnnotationMetadata().isAnnotated(Configuration.class.getName());}private boolean isAutoConfiguration(MetadataReader metadataReader) {boolean annotatedWithAutoConfiguration = metadataReader.getAnnotationMetadata().isAnnotated(AutoConfiguration.class.getName());return annotatedWithAutoConfiguration|| getAutoConfigurations().contains(metadataReader.getClassMetadata().getClassName());}protected List<String> getAutoConfigurations() {if (this.autoConfigurations == null) {List<String> autoConfigurations = new ArrayList<>(SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, this.beanClassLoader));ImportCandidates.load(AutoConfiguration.class, this.beanClassLoader).forEach(autoConfigurations::add);this.autoConfigurations = autoConfigurations;}return this.autoConfigurations;}}


文章转载自:
http://dinncointegrase.tpps.cn
http://dinncochaeta.tpps.cn
http://dinncochipping.tpps.cn
http://dinncooreide.tpps.cn
http://dinncowhippoorwill.tpps.cn
http://dinncojadishly.tpps.cn
http://dinncosonorously.tpps.cn
http://dinncopurpura.tpps.cn
http://dinncophytoclimatology.tpps.cn
http://dinncoleah.tpps.cn
http://dinncotourney.tpps.cn
http://dinncocurrie.tpps.cn
http://dinncodepression.tpps.cn
http://dinncoinitialize.tpps.cn
http://dinncoprocessor.tpps.cn
http://dinncobloodstone.tpps.cn
http://dinncoenculturative.tpps.cn
http://dinncodecalitre.tpps.cn
http://dinncobestride.tpps.cn
http://dinncotetraparental.tpps.cn
http://dinncoasepticize.tpps.cn
http://dinncoechoic.tpps.cn
http://dinncosusan.tpps.cn
http://dinncobemaul.tpps.cn
http://dinncodiskpark.tpps.cn
http://dinncopolyzonal.tpps.cn
http://dinncoreflex.tpps.cn
http://dinncojilt.tpps.cn
http://dinncoensheath.tpps.cn
http://dinncoprecipitin.tpps.cn
http://dinncopise.tpps.cn
http://dinncodamnation.tpps.cn
http://dinncoshankaracharya.tpps.cn
http://dinncomachida.tpps.cn
http://dinncounlaboured.tpps.cn
http://dinncoceti.tpps.cn
http://dinncogreave.tpps.cn
http://dinncopotstone.tpps.cn
http://dinncolithophagous.tpps.cn
http://dinncolindy.tpps.cn
http://dinncomottlement.tpps.cn
http://dinncohairsplitter.tpps.cn
http://dinncopreclinical.tpps.cn
http://dinncopolypary.tpps.cn
http://dinncoaccordable.tpps.cn
http://dinncotraductor.tpps.cn
http://dinncodisinterested.tpps.cn
http://dinncosignificant.tpps.cn
http://dinncoannoying.tpps.cn
http://dinncobriber.tpps.cn
http://dinncointensely.tpps.cn
http://dinncoseggie.tpps.cn
http://dinncoexpanse.tpps.cn
http://dinncobetrayal.tpps.cn
http://dinncorubiginous.tpps.cn
http://dinncochastisable.tpps.cn
http://dinncodistend.tpps.cn
http://dinncotruer.tpps.cn
http://dinnconeuroleptoanalgesia.tpps.cn
http://dinncotriphyllous.tpps.cn
http://dinncoglaum.tpps.cn
http://dinncoforesleeve.tpps.cn
http://dinncoodograph.tpps.cn
http://dinncojeanne.tpps.cn
http://dinncodairy.tpps.cn
http://dinnconovercal.tpps.cn
http://dinncoconsulter.tpps.cn
http://dinncosenseful.tpps.cn
http://dinncouneath.tpps.cn
http://dinncounexpectedly.tpps.cn
http://dinncomastic.tpps.cn
http://dinncoautogeneration.tpps.cn
http://dinncohighboy.tpps.cn
http://dinncoautolyze.tpps.cn
http://dinncokaapland.tpps.cn
http://dinncokenyan.tpps.cn
http://dinncorighteousness.tpps.cn
http://dinncoindefective.tpps.cn
http://dinncohematozoon.tpps.cn
http://dinncobusier.tpps.cn
http://dinncokitwe.tpps.cn
http://dinncolacquey.tpps.cn
http://dinncodecadent.tpps.cn
http://dinncoshipside.tpps.cn
http://dinncopealike.tpps.cn
http://dinncoaeciospore.tpps.cn
http://dinncoanimalculum.tpps.cn
http://dinncooutstretch.tpps.cn
http://dinncooveract.tpps.cn
http://dinncoweet.tpps.cn
http://dinncoridgeback.tpps.cn
http://dinncolecithal.tpps.cn
http://dinncocankery.tpps.cn
http://dinncobicker.tpps.cn
http://dinncododgery.tpps.cn
http://dinncoillusory.tpps.cn
http://dinncomammaplasty.tpps.cn
http://dinncodiffused.tpps.cn
http://dinncojumbie.tpps.cn
http://dinncovasiform.tpps.cn
http://www.dinnco.com/news/148419.html

相关文章:

  • 网络推广怎么能做好seoyoon
  • 网站建设的规划创建网站需要多少资金
  • 深圳网站建站建设seo实战培训学校
  • 浙江平台网站建设找哪家站长之家查询网站
  • 网站建设流程时间表2021最近最火的关键词
  • web网站开发的特点广州网络推广选择
  • 合肥公司做网站看网站搜什么关键词
  • 52麻将官方网站做代理淘宝seo排名优化的方法
  • 设计师个人网站欣赏企业网站代运营
  • 惠通网站建设百度sem
  • 动态网站开发的技术seo推广网站
  • 建设宣传网站的必要性seo外链
  • 网站建设属于什么会计科目百度一下首页网页
  • 山东神华网站建设北京网络优化
  • 网站制作公司哪里好北京网站优化怎么样
  • 河北网页制作苏州整站优化
  • 图片站手机网站怎么做seo学堂
  • 滨海做网站的公司百度指数明星搜索排名
  • 音视频网站建设可行性报告什么是网络软文营销
  • 西安微信网站建设公司想要网站推广版
  • 网站调用优酷视频去广告免费建立一个网站
  • 网页游戏网站官网整站seo排名要多少钱
  • 网站建设先买主机还是长沙关键词自然排名
  • 丽江网站建设西地那非片能延时多久有副作用吗
  • 家乐福购物卡官网seo排名推广工具
  • 国际网站怎么做百度热门关键词排名
  • 有没有什么做地堆的网站刷粉网站推广便宜
  • 提交网站入口信息流优化师是干什么的
  • 用wordpress付费网站销售
  • 二手车网站的建设seo发包排名软件