How to inject a bean only when it exists

前端 未结 2 488
醉梦人生
醉梦人生 2021-01-05 11:28

I have the following structure of spring context files ( -> stands for \'includes\') :

A1.xml -> B.xml & C.xml
A2.xml -> B.xml
         


        
2条回答
  •  不知归路
    2021-01-05 12:31

    I quite agree with cleaning up your XML :-)

    If you're using annotation based injection, you might try this trick

    @Autowired( required=false )
    

    I'm unsure whether this will work in your situation, but it's worth a try.

提交回复
热议问题