gpt4 book ai didi

osgi - 其他 OSGi 包的访问类

转载 作者:行者123 更新时间:2023-12-01 05:46:13 25 4
gpt4 key购买 nike

我的项目有两个包,假设是 Bundle ABundle B

现在 Bundle A 需要从 Bundle B 访问一个类。

我该怎么做?

最佳答案

有两种方式:

  1. 将 bundle B 的依赖添加到 bundle A 的 Manifest 中:Require-Bundle: bundle-id-of-bundle-A
  2. 在 bundle A 的 list 中导入所需类的包:Import-Package: package.of.your.class

在这两种情况下,您都需要在 bundle B 中导出包含您的类的包:Export-Package: package.of.your.class

此外,这里有一个很好的介绍: http://ctpjava.blogspot.com/2010/09/introduction-to-osgi.html

关于osgi - 其他 OSGi 包的访问类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7913197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com