Inject spring dependency in abstract super class

后端 未结 3 1701
忘了有多久
忘了有多久 2020-12-05 13:41

I have requirement to inject dependency in abstract superclass using spring framework.

class A extends AbstractClassB{ 
    private Xdao daox ;
    ...
    p         


        
3条回答
  •  一整个雨季
    2020-12-05 14:10

    You can create an abstract bean definition, and then "subtype" that definition, e.g.

    
         
    
    
    
         
    
    

    Strictly speaking, the definition for b doesn't even require you to specify the class, you can leave that out:

    
         
    
    
    
         
    
    

    However, for clarity, and to give your tools a better chance of helping you out, it's often best to leave it in.

    Section 3.7 of the Spring Manual discusses bean definition inheritance.

提交回复
热议问题