为什么这个 OSGi Import-Package 不起作用?
Why does this OSGi Import-Package not work?
我正在学习这个 OSGi 教程(使用 Eclipse,安装了 PDE 插件):
http://www.vogella.com/tutorials/OSGi/article.html
直到任务 10 一切正常。但是现在我遇到了一个问题:
"Import-Package: org.osgi.framework;version="1.3.0"(自动生成,可能是因为生成的 Activator class)显示以下错误:
"No available bundle exports package 'org.osgi.framework'"
在 Activator class 中,我还遇到了 classes 的解决错误,例如 BundleActivator 和 BundleContext。我通过使用外部 jar (org.eclipse.osgi) 解决了这个问题,但我很确定这不是正确的方法,因为您应该在 MANIFEST 文件中声明任何依赖项。
但是我如何添加 org.eclipse.osgi jar 以便清单中的导入包行就足够了?
我的整个清单文件:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Internal
Bundle-SymbolicName: com.osgi.beispiel.one.bundle.internal
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.osgi.beispiel.one.bundle.Activator
Bundle-Vendor: OSGI
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.osgi.framework;version="1.3.0"
Bundle-ActivationPolicy: lazy
将 org.eclipse.osgi
添加到 MANIFEST.MF 编辑器中“依赖项”选项卡的 'Required Plugins' 部分(这将向 MANIFEST.MF 添加 'Require-Bundle' 行) .
我工作区中出现 "No available bundle exports package 'org.osgi.framework'" 的原因是 ${eclipse_home} 无效。 "Window - Preferences - Target Platform - Running Platform" 处的复选框标有红色图标。我关注了"Edit...",select“${eclipse_home}”,"Edit...",并检查了"This install uses the default configuration area"。用 "Finish" resp 离开对话框后。 "OK",问题解决
这是一个 Eclipse 配置问题;默认情况下,Eclipse 定义了一个用于定位包的路径 - 此路径可能不包含项目所需的包,因此请确保添加可以找到相关包的路径:
我正在学习这个 OSGi 教程(使用 Eclipse,安装了 PDE 插件):
http://www.vogella.com/tutorials/OSGi/article.html
直到任务 10 一切正常。但是现在我遇到了一个问题:
"Import-Package: org.osgi.framework;version="1.3.0"(自动生成,可能是因为生成的 Activator class)显示以下错误: "No available bundle exports package 'org.osgi.framework'"
在 Activator class 中,我还遇到了 classes 的解决错误,例如 BundleActivator 和 BundleContext。我通过使用外部 jar (org.eclipse.osgi) 解决了这个问题,但我很确定这不是正确的方法,因为您应该在 MANIFEST 文件中声明任何依赖项。
但是我如何添加 org.eclipse.osgi jar 以便清单中的导入包行就足够了?
我的整个清单文件:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Internal
Bundle-SymbolicName: com.osgi.beispiel.one.bundle.internal
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.osgi.beispiel.one.bundle.Activator
Bundle-Vendor: OSGI
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: org.osgi.framework;version="1.3.0"
Bundle-ActivationPolicy: lazy
将 org.eclipse.osgi
添加到 MANIFEST.MF 编辑器中“依赖项”选项卡的 'Required Plugins' 部分(这将向 MANIFEST.MF 添加 'Require-Bundle' 行) .
我工作区中出现 "No available bundle exports package 'org.osgi.framework'" 的原因是 ${eclipse_home} 无效。 "Window - Preferences - Target Platform - Running Platform" 处的复选框标有红色图标。我关注了"Edit...",select“${eclipse_home}”,"Edit...",并检查了"This install uses the default configuration area"。用 "Finish" resp 离开对话框后。 "OK",问题解决
这是一个 Eclipse 配置问题;默认情况下,Eclipse 定义了一个用于定位包的路径 - 此路径可能不包含项目所需的包,因此请确保添加可以找到相关包的路径: