I have the following classes defined:
public interface Thingy { ... }
public class Foo implements Thingy { ... }
public class Bar implements Thingy { ... }
Classes Foo and Bar are both instanciated as singleton beans with same names, as in
<bean id="foo" class="Foo" />
<bean id="bar" class="Bar" />
The problem happens then trying to autowire field with same name as bean, like
@Autowired
Thingy foo;
Here, field is autowired with Foo instance, and i don’t want that. If field name doesn’t match bean name, autowiring falis and that’s desired.
So, is there any way to disable such fallback, so autowiring in above case would fail?
I don’t think it’s possible, the other way around it is, using
setFallbackToDefaultTypeMatch:javadoc: CommonAnnotationBeanPostProcessor
Why don’t you just rename either your bean or your class?