【发布时间】:2018-09-11 16:29:08
【问题描述】:
我有依赖于项目 A (com.webfx) 的项目 B (com.embos)。我将项目 A 作为项目 B 中的依赖项导入。 这是我的项目 B 的 pom:
<dependency>
<groupId>com.webfx</groupId>
<artifactId>com.webfx</artifactId>
<version>1.0</version>
<type>jar</type>
</dependency>
当我清理和构建时,它是返回错误:
java.lang.IllegalStateException: 无法加载 ApplicationContext 原因:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“pilahServiceImpl”的bean时出错:通过字段“auditTrailService”表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException:没有“com.webfx.sys.bpm.AuditTrailService”类型的合格 bean 可用:预计至少有 1 个有资格作为自动装配候选者的 bean。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true)} 原因:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“com.webfx.sys.bpm.AuditTrailService”类型的合格bean:预计至少有1个符合自动装配候选资格的bean。依赖注解:{@org.springframework.beans.factory.annotation.Autowired(required=true)}
结果:
错误:
EmbosApplicationTests.contextLoads » IllegalState 无法加载 ApplicationCo...
而在我的PilahServiceImpl 中,那些使用auditTrailService 的是@Autowired.
这是我的 PilahServiceImpl 类:
@Service
public class PilahServiceImpl implements PilahService {
@Autowired
private PilahRepository repoPilah;
@Autowired
private EmbosRepository repoEmbos;
@Autowired
private AuditTrailService auditTrailService;
...
}
为什么会这样?感谢关注
【问题讨论】:
标签: java maven spring-boot dependencies