@Component
public interface IFSClient {
@Nonnull
InventoryPriceDetail getInventoryAndPrice(@Nonnull final IFSRequestPresentation ifsRequestPresentation);
}
MockIFSClient and RestIFSClient has details about how this method will return
InventorySummaryManager looks like
@Component
public class InventorySummaryManager {
private final IFSClient ifsClient;
@Autowired
public InventorySummaryManager(@Nonnull final IFSClient ifsClient) {
this.ifsClient = ifsClient;
}
@Nonnull
public InventorySummaryPresentation getSummary(@Nonnull final InventorySummaryPresentation inventorySummaryRequest) {
final InventoryPriceRequest inventoryPriceRequest = new InventoryPriceRequest(inventorySummaryRequest.getStartDate(),
inventorySummaryRequest.getEndDate(), inventorySummaryRequest.getNetworkId());
final IFSRequestPresentation ifsRequestPresentation = getIfsRequestPresentation(inventoryPriceRequest);
final InventoryPriceDetail inventoryPriceDetail = ifsClient.getInventoryAndPrice(ifsRequestPresentation);
return getInventorySummaryResponse(inventorySummaryRequest, inventoryPriceDetail.getInvListPriceData().get(0));
}
when I start my integration tests using maven-cargo-plugin, I see errors in logs as
[INFO] [talledLocalContainer] SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inventorySummaryManager' defined in URL [jar:file:/Users/harith/IdeaProjects/inventory_api/inventory/integration/target/cargo/configurations/tomcat7x/webapps/inventory/WEB-INF/lib/business-1.0-SNAPSHOT.jar!/com/org/inventory_api/inventory/business/InventorySummaryManager.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.org.inventory_api.external_services.ifs.IFSClient]: : No qualifying bean of type [com.org.inventory_api.external_services.ifs.IFSClient] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Nonnull(when=ALWAYS)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.org.inventory_api.external_services.ifs.IFSClient] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.annotation.Nonnull(when=ALWAYS)}
I am not sure why this bean dependency can not be resolved, can someone please try to correct me?
Solution
I figured that out
My application-context.xml was scanning only inventory module before