osgi - 无法解决 OSGI 未解决的要求:Import-Package: org.osgi.service.event
问题描述
我正在尝试运行 OSGI 捆绑包,但总是收到错误消息Unresolved requirement: Import-Package: org.osgi.service.event
我正在使用带有 OSGI 插件的 IntelliJ
有我的 MANIFEST.MF 文件看起来像
Manifest-Version: 1.0
Bundle-Activator: com.project.g.Publisher
Bundle-ManifestVersion: 2
Bundle-Name: pubs
Bundle-SymbolicName: pubs
Bundle-Version: 1.0.0
Bundle-ClassPath: lib/org.osgi.service.event-1.3.1.jar
Export-Package: com.project.g;uses:="org.osgi.framework";version=
"1.0.0"
Import-Package: org.osgi.service.event,org.eclipse.osgi.util,org.apache.felix.gogo.command,
org.osgi.framework,
org.osgi.util.tracker
代码(来自示例)
public class Publisher extends Thread implements BundleActivator {
Hashtable time = new Hashtable();
ServiceTracker tracker;
@Override
public void start(BundleContext bundleContext) throws Exception {
System.out.println("started");
tracker = new ServiceTracker(bundleContext, EventAdmin.class.getName(), null );
tracker.open();
start();
}
@Override
public void stop(BundleContext bundleContext) throws Exception {
System.out.println("stopped");
}
public void run() {
while ( ! Thread.interrupted() ) try {
Calendar c = Calendar.getInstance();
set(c,Calendar.MINUTE,"minutes");
set(c,Calendar.HOUR,"hours");
set(c,Calendar.DAY_OF_MONTH,"day");
set(c,Calendar.MONTH,"month");
set(c,Calendar.YEAR,"year");
EventAdmin ea =
(EventAdmin) tracker.getService();
if ( ea != null )
ea.sendEvent(new Event("event/start", (Map<String, ?>) time));
Thread.sleep(60000-c.get(Calendar.SECOND)*1000);
} catch( InterruptedException e ) {
return;
}
}
void set(Calendar c, int field, String key ) {
time.put( key, new Integer(c.get(field)) );
}
}
和我的项目结构
我在这里做错了什么?
解决方案
您的捆绑包似乎很好。您只是在运行时缺少包 org.osgi.service.event 的提供者。尝试安装捆绑包 quinox Eventadmin 或 Felix Eventadmin。
推荐阅读
- php - 如何确保更新记录的权限?
- java - getView() 为 null 时无法访问 Fragment View 的 LifecycleOwner
- figma - 如何将 jpg 文件转换为 svg 代码?
- c# - Convert.ToInt32(Console.ReadLine()); 如何 工作?
- java - 如何从Java中的给定段落中找到标题
- markdown - 为什么降价忽略单行换行符?
- python - 使用 REST API 更新字段中的值
- ios - 双向更新 WCSession 的应用程序上下文
- firebase - 将用户信息保存在一个或多个文档中
- azure - 无法使用 [BlobInput] 读取 .xlsx 文件