I have a Spring 2.5/Java/Tomcat application. There is the following bean, which is used throughout the application in many places
publi
What about @Primary?
Indicates that a bean should be given preference when multiple candidates are qualified to autowire a single-valued dependency. If exactly one 'primary' bean exists among the candidates, it will be the autowired value. This annotation is semantically equivalent to the
element's
primary
attribute in Spring XML.
@Primary
public class HibernateDeviceDao implements DeviceDao
Or if you want your Jdbc version to be used by default:
@Primary
is also great for integration testing when you can easily replace production bean with stubbed version by annotating it.