GVKun编程网logo

JFinal Weixin 已经设置了RedisPlugin,获取值时提示Could not get a resource from the pool

1

此处将为大家介绍关于JFinalWeixin已经设置了RedisPlugin,获取值时提示Couldnotgetaresourcefromthepool的详细内容,此外,我们还将为您介绍关于Could

此处将为大家介绍关于JFinal Weixin 已经设置了RedisPlugin,获取值时提示Could not get a resource from the pool的详细内容,此外,我们还将为您介绍关于Could not get a resource from the pool 错误解决、cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)、Hive pmod用法 value = ( (left.get() % right.get()) + right.get() ) % right.get(),查看内置函数的源码、intellij android resource packaging error :resource directory does not exist的有用信息。

本文目录一览:

JFinal Weixin 已经设置了RedisPlugin,获取值时提示Could not get a resource from the pool

JFinal Weixin 已经设置了RedisPlugin,获取值时提示Could not get a resource from the pool



@JFinal 你好,
我在使用JFinal Weixin时,已经在代码中声明RedisPlugin,如下
public void configPlugin(Plugins me) {
// 配置C3p0数据库连接池插件
C3p0Plugin c3p0Plugin = new C3p0Plugin(PropKit.get("jdbcUrl"),
PropKit.get("user"), PropKit.get("password").trim());
me.add(c3p0Plugin);


//设置Redis缓存
RedisPlugin redis = new RedisPlugin("weixin", "localhost");
redis.start();
//me.add(redis);//添加该语句,会使cache对象为空
ApiConfigKit.setAccessTokenCache(new RedisAccessTokenCache());
}




实际使用中,在获取ACCESS_TOKEN时
public static AccessToken getAccessToken() {
String appId = ApiConfigKit.getApiConfig().getAppId();
AccessToken result = null;
try {
result = accessTokenCache.get(appId);
} finally {
if (result != null && result.isAvailable())
return result;

refreshAccessToken();
return accessTokenCache.get(appId);
}
}

accessTokenCache不为空,如图。

但获取不到值,在refreshAccessToken方法中也写不了值,直接报错,提示“Could not get a resource from the pool?”?

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis.clients.util.Pool.getResource(Pool.java:50)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:86)
at com.jfinal.plugin.redis.Cache.getJedis(Cache.java:1202)
at com.jfinal.plugin.redis.Cache.setex(Cache.java:72)
at com.jfinal.weixin.sdk.cache.RedisAccessTokenCache.set(RedisAccessTokenCache.java:19)
at com.jfinal.weixin.sdk.api.AccessTokenApi.refreshAccessToken(AccessTokenApi.java:73)
at com.jfinal.weixin.sdk.api.AccessTokenApi.getAccessToken(AccessTokenApi.java:49)
at com.jfinal.weixin.sdk.api.JsTicketApi.getTicket(JsTicketApi.java:47)
请问是什么原因造成的,如何解决?谢谢。

Could not get a resource from the pool 错误解决

Could not get a resource from the pool 错误解决

错误关键信息:Could not get a resource from the pool

通常原因是因为远程服务器上的redis没有配置好。

解决方案如下:
(1)将redis.conf中的bind:127.0.0.1注释掉;
(2)将redis.conf中的protected-mode yes改为protected-mode no

按照上述的解决方案是可以解决这个问题的。但是以SpringBoot为例,这样做仍然无法解决问题,原因是因为application.yml中的redis配置有误造成的。

按照如下配置即可解决问题:

spring:
  redis:
    host: 192.168.126.128
    port: 2019
    password: youcongtech
    database: 0
    lettuce:
      pool:
        max-active: 32
        max-wait: 300ms
        max-idle: 16
        min-idle: 8

之所以这样配置是因为使用的是spring-boot-starter-data-redis这个maven依赖。当然了,如果你不想这样配置的话大可自己写一个Jedis,不过通常Maven已经提供了,不必自己动手造轮子。

详情可参考如下:
Java连接Redis之redis的增删改查:https://www.cnblogs.com/youcong/p/8098881.html

如果你还没有安装过Redis可以参考我的这篇文章Redis的安装和客户端使用注意事项

cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)

cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)

 “api.weixin.qq.com” 定位是否微信服务器问题,一般不太可能。

1. 首先呢,我们根据出现的问题对问题的故障进行排查,由于后端使用 curl 进行连接的,所以我们首先要保证我们的 curl 连接是正常的,需要测试一下 curl 是否能够正常解析 dns,使用如下命令进行测试工作:

curl api.weixin.qq.com

最终测试结果为 ping 不通!继而我们开始执行对应新的解决方案。

2.ping 不通一般情况下属于 DNS 配置相关的问题,所以我们开始进行编辑修改 DNS 配置文件:

vi /etc/resolv.conf

在源文件的内容基础之下,添加如下两行代码:

nameserver 114.114.114.114

nameserver 8.8.8.8

Hive pmod用法 value = ( (left.get() % right.get()) + right.get() ) % right.get(),查看内置函数的源码

Hive pmod用法 value = ( (left.get() % right.get()) + right.get() ) % right.get(),查看内置函数的源码

"语法: pmod(int a, int b), 返回正的 a 除以 b 的余数"

"语法: pmod(int a, int b), 返回 a 除以 b 的余数的绝对值"

网上几乎都是这样说,但是我实测后发现并不是(hive 2.0.0版本):

但是这个结果为何是3??难道不是1吗??

select pmod(-9,4) // 3

 

但是这个结果为何是-2??难道不是2吗??

select PMOD(6,-4); // -2

hive> desc function pmod ;
  • OK
  • a pmod b - Compute the positive modulo ,很简单,依然看不出所以然
  • Time taken: 0.029 seconds, Fetched: 1 row(s)
  • hive> desc function extended pmod ;
  • OK
  • a pmod b - Compute the positive modulo
  • Time taken: 0.015 seconds, Fetched: 1 row(s)
  • hive> desc function extended upper ;
  • OK
  • upper(str) - Returns str with all characters changed to uppercase
  • Synonyms: ucase
  • Example:
  • > SELECT upper('Facebook') FRO
  • intellij android resource packaging error :resource directory does not exist

    intellij android resource packaging error :resource directory does not exist

    怀疑是乱码导致的。有谁遇到过么??

    project 路径包含中文了 。换成非中文就 ok 了~~

    关于JFinal Weixin 已经设置了RedisPlugin,获取值时提示Could not get a resource from the pool的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于Could not get a resource from the pool 错误解决、cURL error 6: Could not resolve: api.weixin.qq.com (Could not contact DNS servers)、Hive pmod用法 value = ( (left.get() % right.get()) + right.get() ) % right.get(),查看内置函数的源码、intellij android resource packaging error :resource directory does not exist的相关知识,请在本站寻找。

    本文标签:

    上一篇jfinal-weixin pom.xml 怎么设置导出类型为 war(java 导出xml)

    下一篇请问,JFinal-weixin 做了微信支付方面的封装了么?(微信支付 集成)