# bj-starter **Repository Path**: nothanks/bj-starter ## Basic Information - **Project Name**: bj-starter - **Description**: 自定义starter - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-02-16 - **Last Updated**: 2025-02-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 手写starter注意事项 ## 1.springboot2.7.x之前版本 starter工程 - 创建`src/main/resources/META-INF/spring.factories`文件 - spring.factories内容key:`org.springframework.boot.autoconfigure.EnableAutoConfiguration`,value:`你的XxAutoConfiguration全限定名` > 多个value用`逗号`隔开,一行显示不下就用`正斜杠`分割 ## 2.属性配置类,样例如下 ```java @Data @ConfigurationProperties(prefix = "kingdoing") public class User { private String name = "beijing"; } ``` ## 3.XxAutoConfiguration类,样例如下 ```java @Configuration @EnableConfigurationProperties(User.class) //可开启自动注册条件 public class BjAutoConfiguration { @Bean //可开启自动注册条件 public BjServer bjServer() { return new BjServer(); } } public class BjServer { @Autowired User user; public void sayHello() { System.out.println(user.getName()); } } ``` ## 4.pom.xml配置 ```xml org.springframework.boot spring-boot-autoconfigure org.springframework.boot spring-boot-configuration-processor org.projectlombok lombok ``` ## 5.说到最后 - `spring-boot-configuration-processor`表示属性补全提示 ## 6.springboot2.7.x之后新版配置 - 创建`src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`文件 - 内容为:`你的XxAutoConfiguration全限定名` ## 7.其他工程进行引用maven坐标 注入BjServer进行操作