Spring Tool Suite 4 (4.8.1)에서 redis 연결 안될때는 ip주소의 공백문자 확인

2020. 11. 12. 19:47프로그래밍/Java

728x90
반응형

문제 : Spring Tool Suite4 에서 redis에 정상적으로 연결이 되지 않습니다.

원인 : ​application.properties를 이용해서 redis 서버의 ip값을 입력한 경우 공백문자가 포함될 경우 ip주소를 인식하지 못합니다. 

해결 방법 : application.properties의 redis서버의 ip주소 끝의 공백문자 있는지 확인후 삭제

application.properties​ 파일
...<생략>...
#Redis Server
spring.redis.host=133.***.***.124
spring.redis.port=6*7*​
...<생략>...

콘솔창에 다음과 같은 에러들이 출력됩니다.

2020-11-12 18:06:14.050  WARN 18465 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSocketConfig': Unsatisfied dependency expressed through field 'stompHandler'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stompHandler': Unsatisfied dependency expressed through field 'chatRoomRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'chatRoomRepository': Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

...<생략>...

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2020-11-12 18:06:14.141 ERROR 18465 --- [           main] o.s.boot.SpringApplication               : Application run failed

...<생략>...

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stompHandler': Unsatisfied dependency expressed through field 'chatRoomRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'chatRoomRepository': Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

...<생략>...

... 60 common frames omitted

Caused by: redis.clients.jedis.exceptions.JedisConnectionException: Failed connecting to 133.***.***.124 :6379

at redis.clients.jedis.Connection.connect(Connection.java:165) ~[jedis-3.3.0.jar:na]
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:109) ~[jedis-3.3.0.jar:na]
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1904) ~[jedis-3.3.0.jar:na]
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:130) ~[jedis-3.3.0.jar:na]
at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:899) ~[commons-pool2-2.8.1.jar:2.8.1]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:429) ~[commons-pool2-2.8.1.jar:2.8.1]
at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:354) ~[commons-pool2-2.8.1.jar:2.8.1]
at redis.clients.jedis.util.Pool.getResource(Pool.java:50) ~[jedis-3.3.0.jar:na]

... 63 common frames omitted

Caused by: java.net.UnknownHostException: 133.***.***.124
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) ~[na:1.8.0_181]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_181]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_181]
at redis.clients.jedis.DefaultJedisSocketFactory.createSocket(DefaultJedisSocketFactory.java:53) ~[jedis-3.3.0.jar:na]
at redis.clients.jedis.Connection.connect(Connection.java:158) ~[jedis-3.3.0.jar:na]
... 70 common frames omitted​

 

 

    예전 버전의 Spring Tool Suite에서는 공백문자가 있어도 잘 인식을 했지만 업데이트 되면서 문제가 된것 같습니다. 너무 황당하고 예상치 못한 부분에서 에러가 발생하니 한동안 너무 고생을 해서 몇자 적어둡니다.

728x90
반응형