I have a temporal activity class under package
com.x.nl.y.customercare.processes.activity.subscription
Class looks like
@Slf4j
@AllArgsConstructor
@Component
public class ServiceActivitiesImpl implements ServiceActivities {
private final Service service;
@Override
public canBeSavedResponse canBeSaved(CanBeSavedRequest request) {
return service.canBeSaved(request);
}
}
The injected Service bean class is under the package
com.x.nl.y.customercare.service
The issue is Spring cannot inject this service bean into activity due to
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.x.nl.y.customercare.service.Service'
But if I move it into com.x.nl.y.customercare.processes or any subpackage of it then it works.
What's wrong with the service package ?
Seems to me this is an due to incorrect component scanning. Your application is only scanning beans defined in
com.x.nl.y.customercare.processespackage.Make sure that
@ComponentScanor@SpringBootApplicationannotation on you main application class includes the packagecom.x.nl.y.customercare.serviceas well, otherwise spring won't detect it.or using
@SpringBootApplicationor you can simply put
com.x.nl.y.customercareto include both the packages.This can also occur if your main application class is under
com.x.nl.y.customercare.processespackage which by default only scan packages withinprocessesfor any bean definitions.