Spring @Autowired for setter methods vs non-setter methods

前端 未结 3 1732
北海茫月
北海茫月 2021-02-09 18:47

According to @Autowired javadoc:

Marks a constructor, field, setter method or config method as to be autowired by Spring\'s dependency injection facili

3条回答
  •  情书的邮戳
    2021-02-09 19:12

    Config-method in this context refers to methods that you would specify under init-method or @PostConstruct

    Setter as you already know is like setXXX

    So obviously there is no difficulty in finding which is which. At the same time note that spring can not autowire based on parameter names.

提交回复
热议问题