What you are asking is already available in Spring reference
By default, configuration classes use a @Bean method’s name as the
name of the resulting bean. This functionality can be overridden,
however, with the name attribute.
@Configuration
public class AppConfig {
@Bean(name = "myFoo")
public Foo foo() {
return new Foo();
}
}