gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 06:22:02 24 4
gpt4 key购买 nike

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

我有以下类(class):

//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

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

最佳答案

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

关于java - maven-bundle-plugin 中具有相同名称的多个引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47925047/

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