Situation: I have I class with property annotated with @Autowired:
public class MyClass {
@Autowired
protected MyAutoWiredBean myAutowiredBean;
}
Is there any possibility to made wiring this bean optional, i.e. if such bean is defined in some configuration file – to wire it, but if such bean is not defined – just continue working without throwing:
org.springframework.beans.factory.BeanCreationException:
Could not autowire field: protected MyAutoWiredBean...;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No matching bean of type [com.mypackage.MyAutoWiredBean] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
Have you tried:
Javadoc: