@PostConstruct方法在实现类和方法上加注解,类上加bean注解,方法上加@PostConstruct注解。@PostConstruct//启动执行public void refreshAccessToken() throws Exception{WXController wx=(WXController)AppContext.getBean(WXController.class);wx.getAccessToken();}