I have my non-spring public class MySingleton
which has a MyBattis Mapper injected via Spring as follows:
public class MySingleton{
@Autowired
MyMapper myMapper
private List<MyPojo> myList;
private MySingleton(){
myList = myMapper.getMyList();
}
public static MySingleton getInstance(){
if(instance == null){//first check
synchronized (MySingleton.class) {
if(instance == null){// second check
instance = new MySingleton();
}
}
}
return instance;
}
}
myMapper
is never initialized, it's always null on the constructor. I have tested that the bean is declared and created before my Singleton, I have tried Configurable
annotation too and nothing works.
Can anyone help me?