架构设计

自动配置设计

自动配置机制与装配策略。

自动配置设计

nebula-autoconfigure

职责:统一管理所有模块的自动配置

核心机制

@Configuration
@ConditionalOnProperty(prefix = "nebula.data.cache", name = "enabled", havingValue = "true")
@EnableConfigurationProperties(CacheProperties.class)
public class CacheAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public CacheService cacheService(CacheProperties properties) {
        // 根据配置创建缓存服务
        return new CompositeCacheService(properties);
    }
}

配置优先级: 1. 外部配置文件 2. 环境变量 3. 默认配置