How to register multiple beans using single @Bean-annotated method (or similar) in Spring? : <p>I have a class similar to the following:</p>

<pre><code>@Configuration
public class ApplicationConfiguration {

    private &lt;T&gt; T createService(Class&lt;T&gt; serviceInterface) {
        // implementation omitted
    }

    @Bean
    public FooService fooService() {
        return createService(FooService.class);
    }

    @Bean
    public BarService barService() {
        return createService(BarService.class);
    }

    ...

}
</code></pre>

<p>The problem is that there are too many @Bean-annotated methods which differ only in their names, return types and arguments for the <code>crateService</code> method call.
I would like to make this class similar to the following:</p>

<pre><code>@Configuration
public class ApplicationConfiguration {

    private static final Class&lt;?&gt;[] SERVICE_INTERFACES = {
            FooSerivce.class, BarService.class, ...};


    private &lt;T&gt; T createService(Class&lt;T&gt; serviceInterface) {
        // implementation omitted
    }

    @Beans // whatever
    public Map&lt;String, Object&gt; serviceBeans() {
        Map&lt;String, Object&gt; result = ...
        for (Class&lt;?&gt; serviceInterface : SERVICE_INTERFACES) {
            result.put(/* calculated bean name */,
                    createService(serviceInterface));
        }
        return result;
    }

}
</code></pre>

<p>Is it possible in Spring?</p>
