We have a framework built on top of spring and we would like to give devs the ability to override our default beans. So in a case of our “custom themer”, (I wish we didn’t have a custom themer) we have an interface that we autowire into the theme bean.
How can we give the user the ability to implement the same interface and we have that bean autowired into our themer class instead of our default on. Lets say the interface was call NLSER and our default implementation was NLSERConcrete, how can the end user/developer inject CustomerNLSER instead?
Use the
@Primaryannotation orprimary="true"bean attribute in XML. This is your default bean:Now if the developer adds:
to the CLASSPATH and Spring picks it up, it will be preferred in the process of autowiring.