How to load a bean without id or name?
You can load beans by type:
applicationContext.getBeansOfType(xyz.class);
The above will return the map from the (generated) id to the bean instance.
how will spring differentiate if I define 2 beans of the same class without id or name
If you use autwiring by type, it throws an exception (two beans of the same type). You cannot autwire by name because there is no name.
source
share