简体   繁体   中英

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.

Now when I am trying to refer the CoreService in my core module "dd.core" as

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

I am getting bean creation exception,

I have added in my "dd.core" module

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. If you need an implementation for some test in dd.core, you can use a mock instead (or write a test implementation). If you need an implementation in yet another module, you need to depend on dd.core and dd.another in that module. 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.

Check that your dependencies are correctly defined. Does your /dd/another/pom.xml include a dependency to the dd.core artifact?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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