简体   繁体   English

从另一个Maven模块引用接口的实现

[英]Referencing an interface's implementation from another maven module

I have a maven module "dd.core" containing an interface say CoreService, which is implemented in another maven module "dd.another" as CoreServiceImpl. 我有一个maven模块“ dd.core”,其中包含一个接口CoreService,该接口在另一个maven模块“ dd.another”中作为CoreServiceImpl实现。

Now when I am trying to refer the CoreService in my core module "dd.core" as 现在,当我尝试将核心模块“ dd.core”中的CoreService引用为

@Autowired
@Qualifier(value="coreService")
CoreService coreService;

I am getting bean creation exception, 我正在获取bean创建异常,

I have added in my "dd.core" module 我已经在“ dd.core”模块中添加了

How can i resolve this issue ? 我该如何解决这个问题?

Thanks a lot ! 非常感谢 !

Since your interface is implemented in another module, you cannot use that implementation in dd.core. 由于您的接口是在另一个模块中实现的,因此您不能在dd.core中使用实现。 If you need an implementation for some test in dd.core, you can use a mock instead (or write a test implementation). 如果您需要在dd.core中进行某种测试的实现,则可以改用模拟 (或编写测试实现)。 If you need an implementation in yet another module, you need to depend on dd.core and dd.another in that module. 如果需要在另一个模块中实现,则需要在该模块中依赖dd.core和dd.another。 If you need something else, please elaborate. 如果您还有其他需要,请详细说明。

What you cannot do, however, is add a dependency on dd.another in dd.core, otherwise you're introducing a circular dependency. 但是,您不能做的是在dd.core中添加对dd.another的依赖,否则您将引入循环依赖。

Check that your dependencies are correctly defined. 检查是否正确定义了依赖项。 Does your /dd/another/pom.xml include a dependency to the dd.core artifact? 您的/dd/another/pom.xml是否包括对dd.core工件的依赖关系?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM