save成功,但是无法getAccountToken
@IocBean(create="init")
public class WxConfigService {
private WxApi2 wxApi;
@Inject
private PropertiesProxy conf;
public void init() {
WxApi2Impl wxApi = new WxApi2Impl();
/* 从配置信息里面读取各种需要的参数*/
wxApi.configure(conf, "weixin.");
Request request = Request.create("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential", Request.METHOD.GET,"");
Response resp = Sender.create(request).send();
if (!resp.isOK()) {
// return null;
}
Map map = Json.fromJson(WxResp.class, resp.getReader("UTF-8"));
String access_token = String.valueOf(map.get("access_token"));
WxAccessTokenStore store = new MemoryAccessTokenStore();
store.save(access_token,7200, System.currentTimeMillis() / 1000L);
wxApi.setAccessTokenStore(store);
System.out.println("\n--------------------------"+wxApi.getAccessToken());
this.wxApi = wxApi;
}
}
-------------------------------------------------------------
WxApi2Impl wxApi = new WxApi2Impl();
return wxApi.getAccessToken() ;