Spring Boot:自定义模块的自动装配
🏷️ Spring Boot
添加组件扫描的配置类:
java
package me.liujiajia.spring.boot.auto.configuration.sample.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author 佳佳
*/
@Configuration
@ComponentScan(basePackages = {"me.liujiajia.spring.boot.auto.configuration.sample"})
public class MyAutoConfiguration {
}
在 resources 下添加 /META-INF/spring.factories 文件,内容如下:
ini
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
me.liujiajia.spring.boot.auto.configuration.sample.config.MyAutoConfiguration