Allows a property to be autowired if there is exactly one bean of the property type in the application context. If there is more than one, a fatal exception is thrown.

Let’s discuss spring bean autowire by type with below example. In below example we have SortNumbers class which have one dependency for sorting implementation. We use spring bean autowire by type here as we take sortAlgo as property name and in application context there is only one property exist of IsortAlgo type (BubbleSort).

Note: If there is more than one, a fatal exception is thrown or we have to provide the qualify information to help spring for identifying which one it should use.