springboot~3.x和(he)spring.factories說拜拜了
在SpringBoot2.x版本下,公用包在resources/META-INF/spring.factories文件下定義
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.lind.xxx.xxx.xxx
可以實現自動配(pei)置注入,但是(shi)最(zui)近(jin)升級(ji)到3.x后這么定義發現無法生(sheng)效于(yu)是(shi)排(pai)查原因
原因
根據org.springframework.boot.context.annotation.ImportCandidates類中load(Class<?> annotation, ClassLoader classLoader) 方法得知,在SpringBoot3.x中,默認不再是掃描META-INF/spring.factories了,
而是(shi)META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports,這個在springboot 2.7以(yi)(yi)后的(de)版中已經得到(dao)使(shi)用(yong),但那邊spring.factories還是(shi)可以(yi)(yi)用(yong)的(de)。
com.lind.a
com.lind.b
com.lind.c
相關參考