Why do I need a setter for autowired / injected field?

后端 未结 3 1869
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-06 00:16

I have a bean:

    
        

        
3条回答
  •  面向向阳花
    2021-02-06 01:08

    You need to use a setter because annotations are not detected unless spring is told so through either or . Setter is detected because you specified autowire="byType".

    You may find this question and answer helpful as well: When to use autowiring in Spring

提交回复
热议问题