我有一个模块提供接口(interface)的两种实现。我收到编译错误“重复的服务条目:org.util.hsm.api.HSMService”。两个实现都属于同一个模块。
模块信息.java
module org.util.thales.hsm {
uses org.util.hsm.api.HSMService;
provides org.util.hsm.api.HSMService with org.util.hsm.thales.ThalesHSMService;
provides org.util.hsm.api.HSMService with org.util.hsm.safenet.SafeNetHSMService;
}
最佳答案
经过多次尝试和错误,我找到了解决方案。
module org.util.thales.hsm {
uses org.util.hsm.api.HSMService;
provides org.util.hsm.api.HSMService with org.util.hsm.thales.ThalesHSMService, org.util.hsm.safenet.SafeNetHSMService;
}
关于java - 为什么多个实现不允许在 module-info.java 中声明为模块服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57374172/