annotation based factory methods

后端 未结 5 424
無奈伤痛
無奈伤痛 2020-12-11 15:24

I want to be able to autowire a singleton bean (foo)

@Component
public class FooUser {

  @Autowire Foo foo;
}

created by ano

5条回答
  •  庸人自扰
    2020-12-11 16:07

    You need java-config - the @Bean annotation.

    Define your class as @Configuration and your method as @Bean

提交回复
热议问题