【问题标题】:Multiple references with the same name at maven-bundle-plugin在 maven-bundle-plugin 中具有相同名称的多个引用
【发布时间】:2018-06-04 03:15:48
【问题描述】:

我正在使用 maven-bundle-plugin 3.3.0 和 OSGI R6。

我有以下课程:

//Class A
@Component (immediate = true, service = {})
public class A{
    private static B myB;
    @Reference (unbind = "unbindB")
    public static void bindB(B pB)
    {
        myB = pB;
    }

    public static void unbindB()
    {
        myB= null;
    }
}



//B class. It does not implement any interface. Hence, the service must be itself
@Component (immediate = true, service = B.class)
public class B{
@Activate
    public void activate(){
        //B activated
    }
}

运行 mvn clean install 后,maven-bundle-plugin 3.3.0 给了我错误:

Bundle com.X:bundle:0.0.1-SNAPSHOT : In component com.X.A, multiple references with the same name: myB. Previous def: com.X.B, this def:
[ERROR] Error(s) found in bundle configuration

你们有谁知道这可能是错的吗?

【问题讨论】:

    标签: java maven osgi osgi-bundle maven-bundle-plugin


    【解决方案1】:

    绑定/取消绑定方法不能是静态的。您的代码将它们显示为静态。 DS 组件始终基于实例。

    【讨论】:

    • 在这种情况下,错误消息看起来不正确
    • 你说的都是对的。错误信息可能会更好
    猜你喜欢
    • 2014-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-31
    • 2011-09-16
    相关资源
    最近更新 更多