收集整理了一份《2024年最新物联网嵌入式全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升的朋友。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人
都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
[html]
view plain
copy
- @Import({ EnableAutoConfigurationImportSelector.class,
- AutoConfigurationPackages.Registrar.class })
EnableAutoConfigurationImportSelector
来看EnableAutoConfigurationImportSelector类
[html]
view plain
copy
- public String[] selectImports(AnnotationMetadata metadata) {
- try {
- AnnotationAttributes attributes = AnnotationAttributes.fromMap(metadata
- .getAnnotationAttributes(EnableAutoConfiguration.class.getName(),
- true));
- Assert.notNull(attributes, "No auto-configuration attributes found. Is "
- + metadata.getClassName()
- + " annotated with @EnableAutoConfiguration?");
- // Find all possible auto configuration classes, filtering duplicates
- List factories = new ArrayList(new LinkedHashSet(
- SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,
- this.beanClassLoader)));
- // Remove those specifically disabled
- factories.removeAll(Arrays.asList(attributes.getStringArray(“exclude”)));
- // Sort
- factories = new AutoConfigurationSorter(this.resourceLoader)
- .getInPriorityOrder(factories);
- return factories.toArray(new String[factories.size()]);
- }
- catch (IOException ex) {
- throw new IllegalStateException(ex);
- }
- }
看如下代码,获取类路径下spring.factories下key为EnableAutoConfiguration全限定名对应值
[html]
view plain
copy
- SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class,
- this.beanClassLoader))
其结果为:
[html]
view plain
copy
- # Auto Configure
- org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
- org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\
- org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
- org.springframework.boot.autoconfigure.MessageSourceAutoConfiguration,\
- org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration,\
- org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
- org.springframework.boot.autoconfigure.cloud.CloudAutoConfiguration,\
- org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,\
- org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration,\
- org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\
- org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration,\
- org.springframework.boot.autoconfigure.data.solr.SolrRepositoriesAutoConfiguration,\
- org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration,\
- org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\
- org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\
- org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
- org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration,\
- org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\
- org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
- org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
- 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.hornetq.HornetQAutoConfiguration,\
- org.springframework.boot.autoconfigure.jta.JtaAutoConfiguration,\
- org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchAutoConfiguration,\
- org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchDataAutoConfiguration,\
- org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\
- org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\
- org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration,\
- org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration,\
- org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration,\
- org.springframework.boot.autoconfigure.mobile.DeviceResolverAutoConfiguration,\
- org.springframework.boot.autoconfigure.mobile.DeviceDelegatingViewResolverAutoConfiguration,\
- org.springframework.boot.autoconfigure.mobile.SitePreferenceAutoConfiguration,\
- org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\
- org.springframework.boot.autoconfigure.mongo.MongoDataAutoConfiguration,\
- org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
- org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
- org.springframework.boot.autoconfigure.reactor.ReactorAutoConfiguration,\
- org.springframework.boot.autoconfigure.redis.RedisAutoConfiguration,\
- org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,\
- org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration,\
- 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.velocity.VelocityAutoConfiguration,\
- org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
- org.springframework.boot.autoconfigure.web.DispatcherServletAutoConfiguration,\
- org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration,\
- org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration,\
- org.springframework.boot.autoconfigure.web.GzipFilterAutoConfiguration,\
- 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.WebMvcAutoConfiguration,\
- org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration
以上为Spring Boot中所有的自动配置相关类;在启动过程中会解析对应类配置信息,以RabbitMQ为例,则会去解析RabbitAutoConfiguration
RabbitAutoConfiguration
首先来看RabbitAutoConfiguration类上的注解:
[html]
view plain
copy
- @Configuration
- @ConditionalOnClass({ RabbitTemplate.class, Channel.class })
- @EnableConfigurationProperties(RabbitProperties.class)
- @Import(RabbitAnnotationDrivenConfiguration.class)
- public class RabbitAutoConfiguration {
- @Configuration: 应该不需要解释
- @ConditionalOnClass:表示存在对应的Class文件时才会去解析RabbitAutoConfiguration,否则直接跳过不解析,这也是为什么在不导入RabbitMQ依赖Jar时工程能正常启动的原因
- @EnableConfigurationProperties:表示对@ConfigurationProperties的内嵌支持,默认会将对应Class这是为bean,例如这里值为RabbitProperties.class,其定义为:
[html]
view plain
copy
- @ConfigurationProperties(prefix = “spring.rabbitmq”)
- public class RabbitProperties {
- /**
- * RabbitMQ host.
- */
- private String host = “localhost”;
- /**
- * RabbitMQ port.
- */
- private int port = 5672; … //省略部分代码}
RabbitProperties提供对RabbitMQ的配置信息,其前缀为spring.rabbitmq,因此在上篇中配置的host、port等信息会配置到该类上,随后@
EnableConfigurationProperties会将RabbitProperties注册为一个bean。
- @Import为导入配置,RabbitAnnotationDrivenConfiguration具体实现如下:
[html]
view plain
copy
- @Configuration
- @ConditionalOnClass(EnableRabbit.class)
- class RabbitAnnotationDrivenConfiguration {
- @Autowired(required = false)
- private PlatformTransactionManager transactionManager;
- @Bean
- @ConditionalOnMissingBean(name = “rabbitListenerContainerFactory”)
- public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
- ConnectionFactory connectionFactory) {
- SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
- factory.setConnectionFactory(connectionFactory);
- if (this.transactionManager != null) {
- factory.setTransactionManager(this.transactionManager);
- }
- return factory;
- }
- @EnableRabbit
- @ConditionalOnMissingBean(name = RabbitListenerConfigUtils.RABBIT_LISTENER_ANNOTATION_PROCESSOR_BEAN_NAME)
- protected static class EnableRabbitConfiguration {
- }
- }
这里又涉及到一个重要的注解:@ConditionalOnMissingBean,其功能为如果存在指定name的bean,则该注解标注的bean不创建,
[html]
view plain
copy
- @ConditionalOnMissingBean(name = “rabbitListenerContainerFactory”)
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新
me = “rabbitListenerContainerFactory”)
[外链图片转存中…(img-l0wKmwXe-1715684024940)]
[外链图片转存中…(img-nq8GIf28-1715684024941)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新