gpt4 book ai didi

java - BundleActivator 方法未在 OSGi 中得到通知

转载 作者:行者123 更新时间:2023-11-29 08:05:40 24 4
gpt4 key购买 nike

我已经创建了一个带有激活器的包。在启动我的 bundle 时,应该调用激活器方法,但实际上没有。我已经按照教程中提到的相同方式实现了它。

package com.manning.sdmia;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;


public class Activator implements BundleActivator {
private BundleContext context;

public void start(BundleContext context) throws Exception {
System.out.println("In bundle");
}

public void stop(BundleContext context) throws Exception {
System.out.println("In stop");
}
}

这是我的 MANIFEST.MF 文件:

enter code here
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Spring DM Hello World
Bundle-SymbolicName: com.manning.sdmia.helloworld
Bundle-Version:1.0.0
Bundle-Activator: com.manning.sdmia.Activator
Export-Package:com.manning.sdmia
Import-Package: org.osgi.framework

现在,当我使用启动命令从 OSGI 提示符启动 bundle 时,System.out.println 应该在启动时被调用,但它没有打印任何内容。

最佳答案

如果您的 list 看起来像您在此处打印的,则它不是正确的 list 。删除标题名称前的第一行和空格。

关于java - BundleActivator 方法未在 OSGi 中得到通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11429757/

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