0

我正在尝试将其DependencyManager注入我的组件中。被BundleContext注入但DependencyManager不是 ( @Inject)。我究竟做错了什么?

import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.Init;
import org.apache.felix.dm.annotation.api.Inject;
import org.apache.felix.dm.annotation.api.Start;
import org.osgi.framework.BundleContext;

@Component
public class InjectionExample
{
    @Inject
    BundleContext bundleContext;

    @Inject
    DependencyManager manager;

    @Init
    void init()
    {
        System.out.println("Bundle Context: " + bundleContext);
        System.out.println("Manager: " + manager);
    }

    @Start
    void start()
    {
        System.out.println("start");
    }
}
4

1 回答 1

1

我发现了“问题”。在我的项目中,使用了 2 个不同版本的依赖管理器。强制使用一个版本后,它可以工作。

于 2016-12-13T17:07:42.033 回答