08-02-2023, 06:39 AM
I have this Spring config:
<bean id="boo" class="com.x.TheClass"/>
The class `TheClass` implements `TheInterface`. Then I have this (hypothetical) Java code:
@Autowired
TheInterface x;
@Autowired
TheClass y;
The autowiring of `TheInterface` works but the autowiring of `TheClass` fails. Spring gives me a `NoSuchBeanDefinitionException` for the class.
Why can you wire the interface and not the class?
<bean id="boo" class="com.x.TheClass"/>
The class `TheClass` implements `TheInterface`. Then I have this (hypothetical) Java code:
@Autowired
TheInterface x;
@Autowired
TheClass y;
The autowiring of `TheInterface` works but the autowiring of `TheClass` fails. Spring gives me a `NoSuchBeanDefinitionException` for the class.
Why can you wire the interface and not the class?