我有2个应用程序,例如app1和app2。我在app1中使用app2的jar。 app2有一个服务接口,其实现在app1中。我想将app1的serviceImpl注入app2。但它不适用于注释。但它使用xml文件条目。我还在xml中为app2添加了组件扫描。请帮帮我。
App2的:
public interface InterTransactionService {
public List<MappingDetail> getMappingDetailsById(Integer mappingMasterId) throws InterTransactionException;
public List<DimensionMappingDetail> getDimensionMappingDetailsById(Integer mappingDetailId) throws InterTransactionException;
}
App1的:
@Service("interTransactionService")
public class InterTransactionServiceImpl implements InterTransactionService{
//implementation of methods
}
App2的:
@Service
@Scope(value=BeanDefinition.SCOPE_PROTOTYPE,proxyMode=ScopedProxyMode.TARGET_CLASS)
public class ETLImpl extends AbstractInstanceGeneratorService{
@Qualifier("interTransactionService")
@Autowired
private InterTransactionService interTransactionService;
}
例外:
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private xx.generator.InterTransactionService xx.generator.ETLImpl.interTransactionService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [xx.generator.InterTransactionService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=interTransactionService), @org.springframework.beans.factory.annotation.Autowired(required=true)}