从spring 6.0.1或spring boot 3开始  spring的自动装配 已经不能用

spring.factories文件

如:

 

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.example.etcdspringcloudstarter.config.EtcdAutoConfiguration

这样是不生效的 

要么在启动类上使用 @Import

要不然就要换成

Spring Boot 2.7 是最后一个依然兼容使用 spring.factories 的版本,SpringBoot 3 以后不再兼容,此时您应该使用META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports文件替换。

文件中直接写加载的类即可 不需要加入EnableAutoConfiguration之类的

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐