# simple-example-spring-boot-starter **Repository Path**: jeremytech/simple-example-spring-boot-starter ## Basic Information - **Project Name**: simple-example-spring-boot-starter - **Description**: 自定义Spring Boot Starter简单示例 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-02-03 - **Last Updated**: 2021-02-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 工程简介 自定义Spring Boot Starter项目 ### 配置类注解解读 ```java @Configuration @EnableConfigurationProperties(value = {DemoProperties.class}) @ConditionalOnProperty(prefix = "demo", name = "properties", havingValue = "true") public class DemoConfig { private final DemoProperties properties; public DemoConfig(DemoProperties properties) { this.properties = properties; } @Bean(value = "DemoService_1.0") public DemoService getDemoService() { return new DemoService(properties.getName(), properties.getNumber()); } } ``` ▲ @Configuration 注解就不多说了。 ▲ @EnableConfigurationProperties 注解。该注解是用来开启对3步骤中 @ConfigurationProperties 注解配置Bean的支持。也就是@EnableConfigurationProperties注解告诉Spring Boot 能支持@ConfigurationProperties。 当然了,也可以在 @ConfigurationProperties 注解的类上添加 @Configuration 或者 @Component 注解 ▲ @ConditionalOnProperty 注解控制 @Configuration 是否生效。简单来说也就是我们可以通过在yml配置文件中控制 @Configuration 注解的配置类是否生效。 # 延伸阅读