title: Spring java config - create list of beans also created in runtime
body: <p>I have a list of gaming rooms which is created by Spring. Each rooms corresponds some rules (which is enum), and the code is:</p>
  
  <pre><code>@Bean
  List&lt;Room&gt; rooms() {
      return Arrays.stream(Rules.values())
          .map(rule -&gt; new Room(rule))
          .collect(Collectors.toList());
  }
  </code></pre>
  
  <p>But now I need the rooms to be <code>@Beans</code> too: I want Spring to process <code>@EventListener</code> annotation in them. However, I don't want to declare them manually in config as the <code>Rules</code> enum can be updated in the future. How can I solve this problem? Thanks.</p>