maven-bundle-plugin中具有相同名称的多个引用

问题描述 投票:1回答:1

我正在使用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个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.