maven-bundle-plugin 中具有相同名称的多个引用 [英] Multiple references with the same name at maven-bundle-plugin

查看:73
本文介绍了maven-bundle-plugin 中具有相同名称的多个引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 maven-bundle-plugin 3.3.0 和 OSGI R6.

I'm using the maven-bundle-plugin 3.3.0 and 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 出现错误:

After running mvn clean install, the maven-bundle-plugin 3.3.0 gives me the error:

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

你们中有人知道这可能是什么问题吗?

Does any of you know what could it be wrong?

推荐答案

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

The bind/unbind methods cannot be static. Your code shows them as static. DS components are always instance based.

这篇关于maven-bundle-plugin 中具有相同名称的多个引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆