Reputation: 7403
I have a bean which also has a dependency on another bean, both of which are annotated with the same spring conditional:
@Component
@Conditional(ImportEnabledCondition.class)
public class ImportEntityResource {
@Autowired
ImportService importService;
....
}
The importService:
@Component
@Conditional(ImportEnabledCondition.class)
public class ImportService{...}
but I always get the org.springframework.beans.factory.NoSuchBeanDefinitionException
exception.
I'd appreciate any pointers as to how to resolve this issue.
Upvotes: 1
Views: 1228
Reputation: 2017
@Conditional is used to register bean in Spring context depending of some conditions. In your case, you can just remove it as Spring will see the dependency as ImportEntityResource has ImportService as member. If the dependency is less explicit you can use @DependsOn.
Upvotes: 1