【发布时间】:2021-07-28 17:51:42
【问题描述】:
考虑以下我遇到意外错误且无法修复的情况。
在 Opendaylight 原型项目中,当我只在 pom.xml 中声明一个依赖项(即 io-example)时,我只使用了一个类(例如来自 io-example 依赖项的 test.class),没有错误。
但如果我在 pom.xml 中再添加一个依赖项 (io-example-api),我会得到 java.lang.NoClassDefFoundError: io/example/test.class 在 org.opendaylight.gnmi.impl.base.OpenconfigInter ..................................................... ..................................................... 原因:java.lang.ClassNotFoundException: io.example.Test 无法被 org.opendaylight 找到
我发现 io.example-api 有 io-example 作为依赖项。总结问题,如果我在 pom.xml 中只有 io-example,则没有问题。如果我在 pom.xml 中同时包含 io-example 和 io-example-api,则会收到 NoclassDef 错误。
即使我在依赖项部分尝试了排除选项,也没有任何效果。
提前谢谢...
已编辑:
类名:io.grpc.Context
依赖关系:
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-context</artifactId>
<version>1.38.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-api</artifactId>
<version>1.38.0</version>
</dependency>
在 karaf 容器中,我运行了“package:exports”命令,结果是,
opendaylight-user@root>package:exports -p io.grpc
io.grpc 0.0.0 354 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-api_1.38.0_grpc-api-1.38.0.jar
io.grpc 0.0.0 355 wrap_file__home_verizon_gnmi_gnmi_karaf_target_assembly_system_io_grpc_grpc-context_1.38.0_grpc-context-1.38.0.ja
opendaylight-user@root>package:exports -d
io.grpc 0.0.0 354 355
You can see that, io.grpc package exported by two bundles (354 and
355)..
【问题讨论】:
标签: grpc classnotfoundexception noclassdeffounderror apache-karaf opendaylight