Autowiring spring bean by name using annotation

后端 未结 5 509
故里飘歌
故里飘歌 2020-12-23 09:45

In Springs latest version, we can autowire a bean using annotation as @Autowired. This will autowire the bean using its type(or constructor, if applied on it).

5条回答
  •  借酒劲吻你
    2020-12-23 10:17

    Use @Component("beanname") in the java class definition of your bean

    Then while autowiring use JSR 330

    @Inject @Named(Value="beanname")

提交回复
热议问题