@Component类 @Autowired注入为null
解决一:
public class TestBean {
public static TestBean testBean;
@PostConstruct
public void init() {
testBean = this;
testBean .test= this.test;
}
public static TestBean getInstace(){
if(TestBean == null){
synchronized (TestBean .class){
if(testBean== null){
testBean= new TestBean ();
}
}
}
return mvcImgClientMap;
}
解决二:
@Autowired
ApplicationContext applicationContext;
TestBean testBean= (TestBean)applicationContext.getBean("testBean");
然后通过tokenService 获取tokenService 中的接口