java - how to inject parent class property with spring annotation -


parent class this:

public class basedao{     private dbroute defaultdb;      public dbroute getdefaultdb()     {         return this.defaultdb;     }      public void setdefaultdb(dbroute defaultdb)     {         this.defaultdb = defaultdb;     } } 

i have create beans below:

<bean id="adsconfigdb" class="net.flyingfat.common.dbroute.config.dbroute">     <constructor-arg value="adsconfig" /> </bean>  <bean id="adsbizdatedb" class="net.flyingfat.common.dbroute.config.dbroute">     <constructor-arg value="adsbizdate" /> </bean> 

i want inject superclass property defaultdb in subclass through byname, not bytype, in subclass inject defaultdb using adsconfigdb or adsbizdatedb. there way spring annotations? tried autowired or resource constructor doesn't work. way, know can done using xml.

@qualifier annotation – annotation used avoid conflicts in bean mapping , need provide bean name used autowiring. way can avoid issues multiple beans defined same type. annotation works @autowired annotation. constructors multiple arguments, can use annotation argument names in method.

your code this..

@autowired @qualifier("adsconfig") private dbroute defaultdb; 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -