opensolon / solon

🔥 New Java application development framework: FASTER, SMALLER, SIMPLER!! 2 to 3 times more concurrency 50% memory savings Startup is 5-10 times faster. 50% ~ 90% smaller packaging; Compatible with java8 ~ java22.

Home Page:https://solon.noear.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

任务发放:优化 onMissingBean 条件与 List[Bean] 注入的边界问题

noear opened this issue · comments

问题说明:onMissingBean 条件与 List[Bean] 注入的边界

  • onMissingBean 条件的执行时机为,Bean 扫描完成并检查之后才执行的
  • List[Bean](或 Map[String, Bean]) 注入,也是在 Bean 扫描完成后尝试注入的,目前是排在 onMissingBean 函数之后。但,还有谁未完成注册?是不可知的(目前没有做依赖探测)。

像下面的示例,xxxList 是好的,yyyList 可能会傻掉。xxxList 和 yyyList 是相同的注入时机(谁先谁后,无序),此时 Yyy 因为依赖 xxxList,所以并未生成

@Configuration
public class TestConfig{
    @Condition(onMissingBean = Xxx.class)
    @Bean
    public Xxx aaa(){
        ...
    }

    @Condition(onMissingBean = Yyy.class)
    @Bean
    public Yyy bbb(List<Xxx> xxxList ){
        ...
    }

    @Condition(onMissingBean = Zzz.class)
    @Bean
    public Zzz ccc(List<Yyy> yyyList ){
        ...
    }
}

已处理. 2.8.0-SNAPSHOT

此问题已处理。2.8.0 已发布