Reputation: 8609
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?
Upvotes: 2
Views: 2001
Reputation: 4873
You can use @Qualifier("beanname") , to ensure you inject it with the correct bean
Upvotes: 0
Reputation: 42849
I have a couple suggestions to help you out, although I am not sure exactly what you are asking for is possible.
Upvotes: 0
Reputation: 8281
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?
Upvotes: 2