springboot自动配置原理(高低版本比较)spring.factories文件的作用

@SpringBootApplication
public class SpringSecurityApplication {public static void main(String[] args) {SpringApplication.run(SpringSecurityApplication.class, args);}}

注解@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 {
@AliasFor(
annotation = EnableAutoConfiguration.class
)
Class<?>[] exclude() default {};

@AliasFor(annotation = EnableAutoConfiguration.class
)
String[] excludeName() default {};@AliasFor(annotation = ComponentScan.class,attribute = "basePackages"
)
String[] scanBasePackages() default {};@AliasFor(annotation = ComponentScan.class,attribute = "basePackageClasses"
)
Class<?>[] scanBasePackageClasses() default {};@AliasFor(annotation = ComponentScan.class,attribute = "nameGenerator"
)
Class<? extends BeanNameGenerator> nameGenerator() default BeanNameGenerator.class;@AliasFor(annotation = Configuration.class
)
boolean proxyBeanMethods() default true;

}

核心3个注解:
@SpringBootConfiguration     改注解和@Configuration类似,表面这个类是配置类
@EnableAutoConfiguration    springboot实现自动化配置的核心注解
@ComponentScan    默认扫描启动类当前包以及子包要了解springboot自动配置原理当然我们需要看@EnableAutoConfiguration

在这2.4版本以前
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import({EnableAutoConfigurationImportSelector.class})
public @interface EnableAutoConfiguration {
String ENABLED_OVERRIDE_PROPERTY = “spring.boot.enableautoconfiguration”;

Class<?>[] exclude() default {};String[] excludeName() default {};

}

3.4.1版本
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import({AutoConfigurationImportSelector.class})
public @interface EnableAutoConfiguration {
String ENABLED_OVERRIDE_PROPERTY = “spring.boot.enableautoconfiguration”;

Class<?>[] exclude() default {};String[] excludeName() default {};

}

开启自动配置注解我们需要看这个注解做了什么事?
看上面的代码我们可以发现一个关键的@import注解,
低版本:开启导入自动配置选择器:
源码:
@Deprecated
public class EnableAutoConfigurationImportSelector extends AutoConfigurationImportSelector {public EnableAutoConfigurationImportSelector() {}protected boolean isEnabled(AnnotationMetadata metadata) {return this.getClass().equals(EnableAutoConfigurationImportSelector.class) ? (Boolean)this.getEnvironment().getProperty("spring.boot.enableautoconfiguration", Boolean.class, true) : true;}
}
``3.4.1版本
public class AutoConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware, ResourceLoaderAware, BeanFactoryAware, EnvironmentAware, Ordered {static final int ORDER = 2147483646;private static final AutoConfigurationEntry EMPTY_ENTRY = new AutoConfigurationEntry();private static final String[] NO_IMPORTS = new String[0];private static final Log logger = LogFactory.getLog(AutoConfigurationImportSelector.class);private static final String PROPERTY_NAME_AUTOCONFIGURE_EXCLUDE = "spring.autoconfigure.exclude";private final Class<?> autoConfigurationAnnotation;private ConfigurableListableBeanFactory beanFactory;private Environment environment;private ClassLoader beanClassLoader;private ResourceLoader resourceLoader;private volatile ConfigurationClassFilter configurationClassFilter;private volatile AutoConfigurationReplacements autoConfigurationReplacements;public AutoConfigurationImportSelector() {this((Class)null);}AutoConfigurationImportSelector(Class<?> autoConfigurationAnnotation) {this.autoConfigurationAnnotation = autoConfigurationAnnotation != null ? autoConfigurationAnnotation : AutoConfiguration.class;}public String[] selectImports(AnnotationMetadata annotationMetadata) {if (!this.isEnabled(annotationMetadata)) {return NO_IMPORTS;} else {AutoConfigurationEntry autoConfigurationEntry = this.getAutoConfigurationEntry(annotationMetadata);return StringUtils.toStringArray(autoConfigurationEntry.getConfigurations());}}public Predicate<String> getExclusionFilter() {return this::shouldExclude;}private boolean shouldExclude(String configurationClassName) {return this.getConfigurationClassFilter().filter(Collections.singletonList(configurationClassName)).isEmpty();}protected AutoConfigurationEntry getAutoConfigurationEntry(AnnotationMetadata annotationMetadata) {if (!this.isEnabled(annotationMetadata)) {return EMPTY_ENTRY;} else {AnnotationAttributes attributes = this.getAttributes(annotationMetadata);List<String> configurations = this.getCandidateConfigurations(annotationMetadata, attributes);configurations = this.removeDuplicates(configurations);Set<String> exclusions = this.getExclusions(annotationMetadata, attributes);this.checkExcludedClasses(configurations, exclusions);configurations.removeAll(exclusions);configurations = this.getConfigurationClassFilter().filter(configurations);this.fireAutoConfigurationImportEvents(configurations, exclusions);return new AutoConfigurationEntry(configurations, exclusions);}}public Class<? extends DeferredImportSelector.Group> getImportGroup() {return AutoConfigurationGroup.class;}protected boolean isEnabled(AnnotationMetadata metadata) {return this.getClass() == AutoConfigurationImportSelector.class ? (Boolean)this.getEnvironment().getProperty("spring.boot.enableautoconfiguration", Boolean.class, true) : true;}protected AnnotationAttributes getAttributes(AnnotationMetadata metadata) {String name = this.getAnnotationClass().getName();AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(name, true));Assert.notNull(attributes, () -> {String var10000 = metadata.getClassName();return "No auto-configuration attributes found. Is " + var10000 + " annotated with " + ClassUtils.getShortName(name) + "?";});return attributes;}protected Class<?> getAnnotationClass() {return EnableAutoConfiguration.class;}protected List<String> getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) {ImportCandidates importCandidates = ImportCandidates.load(this.autoConfigurationAnnotation, this.getBeanClassLoader());List<String> configurations = importCandidates.getCandidates();Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring/" + this.autoConfigurationAnnotation.getName() + ".imports. If you are using a custom packaging, make sure that file is correct.");return configurations;}private void checkExcludedClasses(List<String> configurations, Set<String> exclusions) {List<String> invalidExcludes = new ArrayList(exclusions.size());Iterator var4 = exclusions.iterator();while(var4.hasNext()) {String exclusion = (String)var4.next();if (ClassUtils.isPresent(exclusion, this.getClass().getClassLoader()) && !configurations.contains(exclusion)) {invalidExcludes.add(exclusion);}}if (!invalidExcludes.isEmpty()) {this.handleInvalidExcludes(invalidExcludes);}}protected void handleInvalidExcludes(List<String> invalidExcludes) {StringBuilder message = new StringBuilder();Iterator var3 = invalidExcludes.iterator();while(var3.hasNext()) {String exclude = (String)var3.next();message.append("\t- ").append(exclude).append(String.format("%n"));}throw new IllegalStateException(String.format("The following classes could not be excluded because they are not auto-configuration classes:%n%s", message));}protected Set<String> getExclusions(AnnotationMetadata metadata, AnnotationAttributes attributes) {Set<String> excluded = new LinkedHashSet();excluded.addAll(this.asList(attributes, "exclude"));excluded.addAll(this.asList(attributes, "excludeName"));excluded.addAll(this.getExcludeAutoConfigurationsProperty());return this.getAutoConfigurationReplacements().replaceAll(excluded);}protected List<String> getExcludeAutoConfigurationsProperty() {Environment environment = this.getEnvironment();if (environment == null) {return Collections.emptyList();} else if (environment instanceof ConfigurableEnvironment) {Binder binder = Binder.get(environment);return (List)binder.bind("spring.autoconfigure.exclude", String[].class).map(Arrays::asList).orElse(Collections.emptyList());} else {String[] excludes = (String[])environment.getProperty("spring.autoconfigure.exclude", String[].class);return excludes != null ? Arrays.asList(excludes) : Collections.emptyList();}}protected List<AutoConfigurationImportFilter> getAutoConfigurationImportFilters() {return SpringFactoriesLoader.loadFactories(AutoConfigurationImportFilter.class, this.beanClassLoader);}private ConfigurationClassFilter getConfigurationClassFilter() {ConfigurationClassFilter configurationClassFilter = this.configurationClassFilter;if (configurationClassFilter == null) {List<AutoConfigurationImportFilter> filters = this.getAutoConfigurationImportFilters();Iterator var3 = filters.iterator();while(var3.hasNext()) {AutoConfigurationImportFilter filter = (AutoConfigurationImportFilter)var3.next();this.invokeAwareMethods(filter);}configurationClassFilter = new ConfigurationClassFilter(this.beanClassLoader, filters);this.configurationClassFilter = configurationClassFilter;}return configurationClassFilter;}private AutoConfigurationReplacements getAutoConfigurationReplacements() {AutoConfigurationReplacements autoConfigurationReplacements = this.autoConfigurationReplacements;if (autoConfigurationReplacements == null) {autoConfigurationReplacements = AutoConfigurationReplacements.load(this.autoConfigurationAnnotation, this.beanClassLoader);this.autoConfigurationReplacements = autoConfigurationReplacements;}return autoConfigurationReplacements;}protected final <T> List<T> removeDuplicates(List<T> list) {return new ArrayList(new LinkedHashSet(list));}protected final List<String> asList(AnnotationAttributes attributes, String name) {String[] value = attributes.getStringArray(name);return Arrays.asList(value);}private void fireAutoConfigurationImportEvents(List<String> configurations, Set<String> exclusions) {List<AutoConfigurationImportListener> listeners = this.getAutoConfigurationImportListeners();if (!listeners.isEmpty()) {AutoConfigurationImportEvent event = new AutoConfigurationImportEvent(this, configurations, exclusions);Iterator var5 = listeners.iterator();while(var5.hasNext()) {AutoConfigurationImportListener listener = (AutoConfigurationImportListener)var5.next();this.invokeAwareMethods(listener);listener.onAutoConfigurationImportEvent(event);}}}protected List<AutoConfigurationImportListener> getAutoConfigurationImportListeners() {return SpringFactoriesLoader.loadFactories(AutoConfigurationImportListener.class, this.beanClassLoader);}private void invokeAwareMethods(Object instance) {if (instance instanceof Aware) {if (instance instanceof BeanClassLoaderAware) {BeanClassLoaderAware beanClassLoaderAwareInstance = (BeanClassLoaderAware)instance;beanClassLoaderAwareInstance.setBeanClassLoader(this.beanClassLoader);}if (instance instanceof BeanFactoryAware) {BeanFactoryAware beanFactoryAwareInstance = (BeanFactoryAware)instance;beanFactoryAwareInstance.setBeanFactory(this.beanFactory);}if (instance instanceof EnvironmentAware) {EnvironmentAware environmentAwareInstance = (EnvironmentAware)instance;environmentAwareInstance.setEnvironment(this.environment);}if (instance instanceof ResourceLoaderAware) {ResourceLoaderAware resourceLoaderAwareInstance = (ResourceLoaderAware)instance;resourceLoaderAwareInstance.setResourceLoader(this.resourceLoader);}}}public void setBeanFactory(BeanFactory beanFactory) throws BeansException {Assert.isInstanceOf(ConfigurableListableBeanFactory.class, beanFactory);this.beanFactory = (ConfigurableListableBeanFactory)beanFactory;}protected final ConfigurableListableBeanFactory getBeanFactory() {return this.beanFactory;}public void setBeanClassLoader(ClassLoader classLoader) {this.beanClassLoader = classLoader;}protected ClassLoader getBeanClassLoader() {return this.beanClassLoader;}public void setEnvironment(Environment environment) {this.environment = environment;}protected final Environment getEnvironment() {return this.environment;}public void setResourceLoader(ResourceLoader resourceLoader) {this.resourceLoader = resourceLoader;}protected final ResourceLoader getResourceLoader() {return this.resourceLoader;}public int getOrder() {return 2147483646;}protected static class AutoConfigurationEntry {private final List<String> configurations;private final Set<String> exclusions;private AutoConfigurationEntry() {this.configurations = Collections.emptyList();this.exclusions = Collections.emptySet();}AutoConfigurationEntry(Collection<String> configurations, Collection<String> exclusions) {this.configurations = new ArrayList(configurations);this.exclusions = new HashSet(exclusions);}public List<String> getConfigurations() {return this.configurations;}public Set<String> getExclusions() {return this.exclusions;}}private static class ConfigurationClassFilter {private final AutoConfigurationMetadata autoConfigurationMetadata;private final List<AutoConfigurationImportFilter> filters;ConfigurationClassFilter(ClassLoader classLoader, List<AutoConfigurationImportFilter> filters) {this.autoConfigurationMetadata = AutoConfigurationMetadataLoader.loadMetadata(classLoader);this.filters = filters;}List<String> filter(List<String> configurations) {long startTime = System.nanoTime();String[] candidates = StringUtils.toStringArray(configurations);boolean skipped = false;Iterator var6 = this.filters.iterator();int i;while(var6.hasNext()) {AutoConfigurationImportFilter filter = (AutoConfigurationImportFilter)var6.next();boolean[] match = filter.match(candidates, this.autoConfigurationMetadata);for(i = 0; i < match.length; ++i) {if (!match[i]) {candidates[i] = null;skipped = true;}}}if (!skipped) {return configurations;} else {List<String> result = new ArrayList(candidates.length);String[] var12 = candidates;int var14 = candidates.length;for(i = 0; i < var14; ++i) {String candidate = var12[i];if (candidate != null) {result.add(candidate);}}if (AutoConfigurationImportSelector.logger.isTraceEnabled()) {int numberFiltered = configurations.size() - result.size();AutoConfigurationImportSelector.logger.trace("Filtered " + numberFiltered + " auto configuration class in " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime) + " ms");}return result;}}}private static final class AutoConfigurationGroup implements DeferredImportSelector.Group, BeanClassLoaderAware, BeanFactoryAware, ResourceLoaderAware {private final Map<String, AnnotationMetadata> entries = new LinkedHashMap();private final List<AutoConfigurationEntry> autoConfigurationEntries = new ArrayList();private ClassLoader beanClassLoader;private BeanFactory beanFactory;private ResourceLoader resourceLoader;private AutoConfigurationMetadata autoConfigurationMetadata;private AutoConfigurationReplacements autoConfigurationReplacements;private AutoConfigurationGroup() {}public void setBeanClassLoader(ClassLoader classLoader) {this.beanClassLoader = classLoader;}public void setBeanFactory(BeanFactory beanFactory) {this.beanFactory = beanFactory;}public void setResourceLoader(ResourceLoader resourceLoader) {this.resourceLoader = resourceLoader;}public void process(AnnotationMetadata annotationMetadata, DeferredImportSelector deferredImportSelector) {Assert.state(deferredImportSelector instanceof AutoConfigurationImportSelector, () -> {return String.format("Only %s implementations are supported, got %s", AutoConfigurationImportSelector.class.getSimpleName(), deferredImportSelector.getClass().getName());});AutoConfigurationImportSelector autoConfigurationImportSelector = (AutoConfigurationImportSelector)deferredImportSelector;AutoConfigurationReplacements autoConfigurationReplacements = autoConfigurationImportSelector.getAutoConfigurationReplacements();Assert.state(this.autoConfigurationReplacements == null || this.autoConfigurationReplacements.equals(autoConfigurationReplacements), "Auto-configuration replacements must be the same for each call to process");this.autoConfigurationReplacements = autoConfigurationReplacements;AutoConfigurationEntry autoConfigurationEntry = autoConfigurationImportSelector.getAutoConfigurationEntry(annotationMetadata);this.autoConfigurationEntries.add(autoConfigurationEntry);Iterator var6 = autoConfigurationEntry.getConfigurations().iterator();while(var6.hasNext()) {String importClassName = (String)var6.next();this.entries.putIfAbsent(importClassName, annotationMetadata);}}public Iterable<DeferredImportSelector.Group.Entry> selectImports() {if (this.autoConfigurationEntries.isEmpty()) {return Collections.emptyList();} else {Set<String> allExclusions = (Set)this.autoConfigurationEntries.stream().map(AutoConfigurationEntry::getExclusions).flatMap(Collection::stream).collect(Collectors.toSet());Set<String> processedConfigurations = (Set)this.autoConfigurationEntries.stream().map(AutoConfigurationEntry::getConfigurations).flatMap(Collection::stream).collect(Collectors.toCollection(LinkedHashSet::new));processedConfigurations.removeAll(allExclusions);return this.sortAutoConfigurations(processedConfigurations, this.getAutoConfigurationMetadata()).stream().map((importClassName) -> {return new DeferredImportSelector.Group.Entry((AnnotationMetadata)this.entries.get(importClassName), importClassName);}).toList();}}private AutoConfigurationMetadata getAutoConfigurationMetadata() {if (this.autoConfigurationMetadata == null) {this.autoConfigurationMetadata = AutoConfigurationMetadataLoader.loadMetadata(this.beanClassLoader);}return this.autoConfigurationMetadata;}private List<String> sortAutoConfigurations(Set<String> configurations, AutoConfigurationMetadata autoConfigurationMetadata) {MetadataReaderFactory var10002 = this.getMetadataReaderFactory();AutoConfigurationReplacements var10004 = this.autoConfigurationReplacements;Objects.requireNonNull(var10004);return (new AutoConfigurationSorter(var10002, autoConfigurationMetadata, var10004::replace)).getInPriorityOrder(configurations);}private MetadataReaderFactory getMetadataReaderFactory() {try {return (MetadataReaderFactory)this.beanFactory.getBean("org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory", MetadataReaderFactory.class);} catch (NoSuchBeanDefinitionException var2) {return new CachingMetadataReaderFactory(this.resourceLoader);}}}
}

在这里插入图片描述

对于spring.factories文件
3.4.1版本
# Auto Configuration Import Filters
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\
org.springframework.boot.autoconfigure.condition.OnBeanCondition,\
org.springframework.boot.autoconfigure.condition.OnClassCondition,\
org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition1.5.2版本
# Auto Configuration Import Filters
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\
org.springframework.boot.autoconfigure.condition.OnClassCondition

3.4.1版本可以看到,实现方式发生了变化,引入了配置类过滤器ConfigurationClassFilter来完成bean自动配置的加载
在这里插入图片描述
调用getAutoConfigurationEntry来获取要自动配置的类放入AutoConfigurationEntry对象,这个对象包含2个集合,一个是要自动配置的集合,一个是排除自动配置的集合
在这里插入图片描述在这里插入图片描述
spring会跟进这两个集合完成自动配置

低版本的只需要读取spring.factories文件,获取自动配置类进行自动加载bean

spring.factories文件自动配置信息

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\
org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\
org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\
org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\
org.springframework.boot.autoconfigure.cloud.CloudAutoConfiguration,\
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,\
org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration,\
org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.couchbase.CouchbaseRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.ldap.LdapDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,\
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\
org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration,\
org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration,\
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration,\
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,\
org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration,\
org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration,\
org.springframework.boot.autoconfigure.jms.JndiConnectionFactoryAutoConfiguration,\
org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration,\
org.springframework.boot.autoconfigure.jms.artemis.ArtemisAutoConfiguration,\
org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\
org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration,\
org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,\
org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration,\
org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration,\
org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration,\
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration,\
org.springframework.boot.autoconfigure.mail.MailSenderValidatorAutoConfiguration,\
org.springframework.boot.autoconfigure.mobile.DeviceResolverAutoConfiguration,\
org.springframework.boot.autoconfigure.mobile.DeviceDelegatingViewResolverAutoConfiguration,\
org.springframework.boot.autoconfigure.mobile.SitePreferenceAutoConfiguration,\
org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,\
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\
org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration,\
org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,\
org.springframework.boot.autoconfigure.security.SecurityFilterAutoConfiguration,\
org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration,\
org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration,\
org.springframework.boot.autoconfigure.sendgrid.SendGridAutoConfiguration,\
org.springframework.boot.autoconfigure.session.SessionAutoConfiguration,\
org.springframework.boot.autoconfigure.social.SocialWebAutoConfiguration,\
org.springframework.boot.autoconfigure.social.FacebookAutoConfiguration,\
org.springframework.boot.autoconfigure.social.LinkedInAutoConfiguration,\
org.springframework.boot.autoconfigure.social.TwitterAutoConfiguration,\
org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration,\
org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration,\
org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,\
org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.web.HttpEncodingAutoConfiguration,\
org.springframework.boot.autoconfigure.web.HttpMessageConvertersAutoConfiguration,\
org.springframework.boot.autoconfigure.web.MultipartAutoConfiguration,\
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration,\
org.springframework.boot.autoconfigure.web.WebClientAutoConfiguration,\
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration,\
org.springframework.boot.autoconfigure.websocket.WebSocketMessagingAutoConfiguration,\
org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration总结:
1.通过@SpringBootConfiguration 引入了@EnableAutoConfiguration(负责启动自动配置功能)
2.@EnableAutoConfiguration引入了@Import
3.Spring容器启动时:加载loc容器时会解析@Import 注解
4.@lmport导入了一个deferredlmportSelector,它会使SpringBoot的自动配置类的顺序在最后,这样方便我们扩展和覆盖?
5.然后读取所有的/META-INF/spring.factories文件(SPI)
6.过滤出所有AutoConfigurtionClass类型的类
7.最后通过@Condition排除无效的自动配置类

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/66598.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

vue2 - Day05 - VueX

Vuex 是 Vue.js 官方的状态管理库。它是一个让你能在应用中集中管理共享状态的工具。当应用的规模逐渐增大&#xff0c;组件之间的数据传递变得越来越复杂时&#xff0c;Vuex 就成为了救星&#xff0c;提供了一个集中式的存储来管理所有的组件状态&#xff0c;并且保证状态以一…

IDEA导入Maven工程不识别pom.xml

0 现象 把阿里 sentinel 项目下载本地后&#xff0c;IDEA 中却没显示 maven 工具栏。 1 右键Maven Projects 点击IDEA右侧边栏的Maven Projects&#xff0c;再点击&#xff1a; 在出现的选择框中选择指定的未被识别的pom.xml即可&#xff1a; 2 Add as maven project 右键p…

VUE学习笔记(入门)5__vue指令v-html

v-html是用来解析字符串标签 示例 <!doctype html> <html lang"en"> <head><meta charset"UTF-8" /><meta name"viewport" content"widthdevice-width, initial-scale1.0" /><title>Document<…

OSPF的LSA的学习研究

OSPF常见1、2、3、4、5、7类LSA的研究 1、拓扑如图&#xff0c;按照地址表配置&#xff0c;激活OSPF划分相关区域并宣告相关网段 2、1类LSA&#xff0c;每台运行了OSPF的路由器都会产生&#xff0c;描述了路由器的直连接口状况和cost 可以看到R1产生了一条router lsa&#xff0…

Java - WebSocket

一、WebSocket 1.1、WebSocket概念 WebSocket是一种协议&#xff0c;用于在Web应用程序和服务器之间建立实时、双向的通信连接。它通过一个单一的TCP连接提供了持久化连接&#xff0c;这使得Web应用程序可以更加实时地传递数据。WebSocket协议最初由W3C开发&#xff0c;并于2…

stm32 no connect target

解决 STM32 报错 “no target connected” 的方法 前言 stm32最小系统在下载程序是一直报错&#xff1a;no target connected&#xff0c;试了很多办法成功不了&#xff0c;最后将芯片擦除了才成功。 一、问题描述 当时是写flash的时候写到ST Link 存储的地方了。 之后就不…

Open3D计算点云粗糙度(方法一)【2025最新版】

目录 一、Roughness二、代码实现三、结果展示博客长期更新,本文最近更新时间为:2025年1月18日。 一、Roughness 通过菜单栏的Tools > Other > Roughness找到该功能。 这个工具可以估计点云的“粗糙度”。 选择一个或几个点云,然后启动这个工具。 CloudCompare只会询问…

窥探QCC518x/308x系列与手机之间的蓝牙HCI记录与分析 - 手机篇

今天要介绍给大家的是, 当我们在开发高通耳机时如果遇到与手机之间相容性问题, 通常会用Frontline或Ellisys的Bluetooth Analyzer来截取资料分析, 如果手边没有这样的仪器, 要如何窥探Bluetooth的HCI log.这次介绍的是手机篇. 这次跟QCC518x/QCC308x测试的手机是Samsung S23 U…

【论文投稿】Python 网络爬虫:探秘网页数据抓取的奇妙世界

目录 前言 一、Python—— 网络爬虫的绝佳拍档 二、网络爬虫基础&#xff1a;揭开神秘面纱 &#xff08;一&#xff09;工作原理&#xff1a;步步为营的数据狩猎 &#xff08;二&#xff09;分类&#xff1a;各显神通的爬虫家族 三、Python 网络爬虫核心库深度剖析 &…

前端炫酷动画--图片(一)

目录 一、四角线框的跟随移动 二、元素倒影(-webkit-box-reflect) 三、模特换装(maskblend) 四、元素平滑上升 五、无限视差滚动 六、判断鼠标进入方向(轮播方向) 七、环形旋转效果 八、黑白小球交替旋转 九、hover时圆形放大 十、画一棵随机树(canvas) 十一、代码雨…

STL--list(双向链表)

目录 一、list 对象创建 1、默认构造函数 2、初始化列表 3、迭代器 4、全0初始化 5、全值初始化 6、拷贝构造函数 二、list 赋值操作 1、赋值 2、assign&#xff08;迭代器1&#xff0c;迭代器2&#xff09; 3、assign&#xff08;初始化列表&#xff09; 4、assig…

【语言处理和机器学习】概述篇(基础小白入门篇)

前言 自学笔记&#xff0c;分享给语言学/语言教育学方向的&#xff0c;但对语言数据处理感兴趣但是尚未入门&#xff0c;却需要在论文中用到的小伙伴&#xff0c;欢迎大佬们补充或绕道。ps&#xff1a;本文不涉及公式讲解&#xff08;文科生小白友好体质&#xff09;&#xff…

小程序获取微信运动步数

1、用户点击按钮&#xff0c;在小程序中触发getuserinfo方法&#xff0c;获取用户信息 <scroll-view class"scrollarea" scroll-y type"list"><view class"container"><button bind:tap"getLogin">获取</button&…

C 语言雏启:擘画代码乾坤,谛观编程奥宇之初瞰

大家好啊&#xff0c;我是小象٩(๑ω๑)۶ 我的博客&#xff1a;Xiao Xiangζั͡ޓއއ 很高兴见到大家&#xff0c;希望能够和大家一起交流学习&#xff0c;共同进步。* 这一课主要是让大家初步了解C语言&#xff0c;了解我们的开发环境&#xff0c;main函数&#xff0c;库…

VSCode下EIDE插件开发STM32

VSCode下STM32开发环境搭建 本STM32教程使用vscode的EIDE插件的开发环境&#xff0c;完全免费&#xff0c;有管理代码文件的界面&#xff0c;不需要其它IDE。 视频教程见本人的 VSCodeEIDE开发STM32 安装EIDE插件 Embedded IDE 嵌入式IDE 这个插件可以帮我们管理代码文件&am…

Linux内核编程(二十一)USB驱动开发

一、驱动类型 USB 驱动开发主要分为两种&#xff1a;主机侧的驱动程序和设备侧的驱动程序。一般我们编写的都是主机侧的USB驱动程序。 主机侧驱动程序用于控制插入到主机中的 USB 设备&#xff0c;而设备侧驱动程序则负责控制 USB 设备如何与主机通信。由于设备侧驱动程序通常与…

论文笔记-arXiv2025-A survey about Cold Start Recommendation

论文笔记-arXiv2025-Cold-Start Recommendation towards the Era of Large Language Models: A Comprehensive Survey and Roadmap 面向大语言模型&#xff08;LLMs&#xff09;时代的冷启动推荐&#xff1a;全面调研与路线图1.引言2.前言3.内容特征3.1数据不完整学习3.1.1鲁棒…

C#使用WMI获取控制面板中安装的所有程序列表

C#使用WMI获取控制面板中安装的所有程序列表 WMI 全称Windows Management Instrumentation,Windows Management Instrumentation是Windows中用于提供共同的界面和对象模式以便访问有关操作系统、设备、应用程序和服务的管理信息。如果此服务被终止&#xff0c;多数基于 Windo…

风光并网对电网电能质量影响的matlab/simulink仿真建模

这个课题早在一几年的时候比较热门&#xff0c;之前作电科院配电网的一个项目中也有所涉及&#xff0c;我把其中一部分经典仿真模型思路分享给大家&#xff0c;电能质量影响这部分&#xff0c;我在模型中主要体现的就是不同容量的光伏、风电接入&#xff0c;对并网点的电压影响…

.Net Core微服务入门全纪录(六)——EventBus-事件总线

系列文章目录 1、.Net Core微服务入门系列&#xff08;一&#xff09;——项目搭建 2、.Net Core微服务入门全纪录&#xff08;二&#xff09;——Consul-服务注册与发现&#xff08;上&#xff09; 3、.Net Core微服务入门全纪录&#xff08;三&#xff09;——Consul-服务注…