问题
I'm using the maven-bundle-plugin 3.3.0 and OSGI R6.
I have the following classes:
//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
}
}
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?
回答1:
The bind/unbind methods cannot be static. Your code shows them as static. DS components are always instance based.
来源:https://stackoverflow.com/questions/47925047/multiple-references-with-the-same-name-at-maven-bundle-plugin