We recently encountered an issue where we had a bean being injected using the @Resource annotation. This was working fine but we have been moving over to the @Inject annotation as our preferred method of injecting beans.
What we found however was that when we changed one of our beans to use @Inject instead of @Resource then a large number of our tests began to fail with the exception:
Error creating bean with name 'myBean': Injection of autowired dependencies failed
Sample code:
@Component
public class MyClassImpl implements MyParentClass {
@Resource
private MyBean myBean;
}
Could anyone advise on situations where @Inject would not work but @Resource would?