赞
踩
public class EnableAutoConfigurationImportSelector implements DeferredImportSelector, BeanClassLoaderAware { private ClassLoader classLoader; @Override public String[] selectImports(AnnotationMetadata importingClassMetadata) { List<String> configurations = SpringFactoriesLoader.loadFactoryNames(EnableAutoConfiguration.class, classLoader); if (configurations.size() != 0){ return StringUtils.toStringArray(configurations); } return new String[0]; } @Override public void setBeanClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; }
@EnableDiscoveryClient
@SpringBootApplication
//导入刚刚创建的类
@Import(value = EnableAutoConfigurationImportSelector.class)
public class Java17DemoApplication {
public static void main(String[] args) {
SpringApplication.run(Java17DemoApplication.class, args);
}
}
springboot2扫描的是META-INF/spring.factories文件
springboot3扫描的是META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.import
这是springboot2的扫描路径
这是升级到了springboot3时 扫描的文件路径
所以 升级到springboot3时 因为没有META-INF/spring.factories了 所以这个文件下的自动配置类就没有加载到ioc容器中
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。