我有一些带有一些简单映射的AbstractComponent。然后我有ManagerBean,它是spring bean,我需要AbstractComponent.myMap,但它是null ...
AbstractComponent
public class AbstractComponent {
public static Map<TypeA, SomeFunctionAPI> myMap = new HashMap<>();
static {
myMap.put(TypeA.X, new SomeFunctionAPI(){}); //anonymous implementation depending on TypeA
myMap.put(TypeA.F, new SomeFunctionAPI(){});
}
ManagerBean
public ManagerBean {
public void dosomething(){
AbstractComponent.myMap; //myMap is null
}
弹簧
<bean id="managerBean" class="myPckage.ManagerBean">