gpt4 book ai didi

java - 在 Virtual Box 上为 Spring Boot 应用程序运行 WAR 时出错

转载 作者:可可西里 更新时间:2023-11-01 11:18:32 26 4
gpt4 key购买 nike

我正在尝试在 Virtual Box 上运行由 MongoDBRedis Server 组成的 Spring Boot 应用程序,但出现与 redis 相关的错误,因此无法完成该过程..我收到这些错误:

vb-be7e6bc7 -> Caused by: org.springframework.data.redis.RedisConnectionFailureE
xception: Cannot get Jedis connection; nested exception is redis.clients.jedis.e
xceptions.JedisConnectionException: Could not get a resource from the pool
vb-be7e6bc7 -> at org.springframework.data.redis.connection.jedis.JedisConnecti
onFactory.fetchJedisConnector(JedisConnectionFactory.java:198) ~[spring-data-red
is-1.7.2.RELEASE.jar!/:na]
vb-be7e6bc7 -> at org.springframework.data.redis.connection.jedis.JedisConnecti
onFactory.getConnection(JedisConnectionFactory.java:345) ~[spring-data-redis-1.7
.2.RELEASE.jar!/:na]
vb-be7e6bc7 -> at org.springframework.session.data.redis.config.annotation.web.
http.RedisHttpSessionConfiguration$EnableRedisKeyspaceNotificationsInitializer.a
fterPropertiesSet(RedisHttpSessionConfiguration.java:223) ~[spring-session-1.2.1
.RELEASE.jar!/:na]
vb-be7e6bc7 -> at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
vb-be7e6bc7 -> at org.springframework.beans.factory.support.AbstractAutowireCap
ableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[s
pring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
vb-be7e6bc7 -> ... 24 common frames omitted
vb-be7e6bc7 -> Caused by: redis.clients.jedis.exceptions.JedisConnectionExceptio
n: Could not get a resource from the pool
vb-be7e6bc7 -> at redis.clients.util.Pool.getResource(Pool.java:53) ~[jedis-2.8
.2.jar!/:na]
vb-be7e6bc7 -> at redis.clients.jedis.JedisPool.getResource(JedisPool.java:99)
~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 -> at redis.clients.jedis.JedisPool.getResource(JedisPool.java:12)
~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 -> at org.springframework.data.redis.connection.jedis.JedisConnecti
onFactory.fetchJedisConnector(JedisConnectionFactory.java:191) ~[spring-data-red
is-1.7.2.RELEASE.jar!/:na]
vb-be7e6bc7 -> ... 28 common frames omitted
vb-be7e6bc7 -> Caused by: redis.clients.jedis.exceptions.JedisConnectionExceptio
n: java.net.ConnectException: Connection refused
vb-be7e6bc7 -> at redis.clients.jedis.Connection.connect(Connection.java:164) ~
[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 -> at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:80
) ~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 -> at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1677
) ~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 -> at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java
:87) ~[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 -> at org.apache.commons.pool2.impl.GenericObjectPool.create(Generi
cObjectPool.java:868) ~[commons-pool2-2.4.2.jar!/:2.4.2]
vb-be7e6bc7 -> at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
GenericObjectPool.java:435) ~[commons-pool2-2.4.2.jar!/:2.4.2]
vb-be7e6bc7 -> at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(
GenericObjectPool.java:363) ~[commons-pool2-2.4.2.jar!/:2.4.2]
vb-be7e6bc7 -> at redis.clients.util.Pool.getResource(Pool.java:49) ~[jedis-2.8
.2.jar!/:na]
vb-be7e6bc7 -> ... 31 common frames omitted
vb-be7e6bc7 -> Caused by: java.net.ConnectException: Connection refused
vb-be7e6bc7 -> at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.
8.0-8u102]
vb-be7e6bc7 -> at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocke
tImpl.java:350) ~[na:1.8.0-8u102]
vb-be7e6bc7 -> at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPla
inSocketImpl.java:206) ~[na:1.8.0-8u102]
vb-be7e6bc7 -> at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketI
mpl.java:188) ~[na:1.8.0-8u102]
vb-be7e6bc7 -> at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[
na:1.8.0-8u102]
vb-be7e6bc7 -> at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0-8u102]
vb-be7e6bc7 -> at redis.clients.jedis.Connection.connect(Connection.java:158) ~
[jedis-2.8.2.jar!/:na]
vb-be7e6bc7 -> ... 38 common frames omitted

我尝试了以下但没有成功:

最佳答案

看起来像是连接问题,请验证以下内容:

配置不匹配

在您的 redis redis.conf 文件中找到绑定(bind)配置和默认端口

bind 127.0.0.1
port 6379

JedisConnectionFactory 使用的 jedis 默认值(查看您的堆栈跟踪)是:

bind localhost
port 6379

查看jedis客户端Protocol和 Spring 数据 JedisConnectionFactory类。

确保它们与您的 spring-boot 应用程序配置相匹配如果不使用 JedisShardInfo要更新您的配置,JedisConnectionFactory 在其构造函数中接受 JedisShardInfo。

确保您的/etc/hosts 或 c:\windows\system32\drivers\etc\hosts有条目

127.0.0.1       localhost

尽管有些琐碎,但有时有人会更改或删除它。

Redis 启动失败

确保您的 redis 已启动并正在运行,也许其他进程正在使用 redis 端口。使用

netstat –anp | grep 6379

或 window

netstat –ano | find “6379”

如果发现其他进程使用该端口,则相应调整

另见 What can be the reasons of connection refused errors?

关于java - 在 Virtual Box 上为 Spring Boot 应用程序运行 WAR 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40700907/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com