{"id":201827,"date":"2025-05-10T08:19:40","date_gmt":"2025-05-10T00:19:40","guid":{"rendered":"https:\/\/server.hk\/cnblog\/201827\/"},"modified":"2025-05-10T08:19:40","modified_gmt":"2025-05-10T00:19:40","slug":"unable-to-connect-to-redis%e6%97%a0%e6%b3%95%e8%bf%9e%e6%8e%a5%e5%88%b0redis%e8%a7%a3%e5%86%b3%e7%9a%84%e5%85%a8%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/201827\/","title":{"rendered":"Unable\u00a0to\u00a0connect\u00a0to\u00a0Redis\u65e0\u6cd5\u8fde\u63a5\u5230Redis\u89e3\u51b3\u7684\u5168\u8fc7\u7a0b"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>Unable&nbsp;to&nbsp;connect&nbsp;to&nbsp;Redis\u65e0\u6cd5\u8fde\u63a5\u5230Redis\u89e3\u51b3\u7684\u5168\u8fc7\u7a0b<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5728\u6570\u636e\u5e93\u5b9e\u6218\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8981\u5361\u597d\u534a\u5929\uff0c\u7b49\u95ee\u9898\u89e3\u51b3\u4e86\u624d\u53d1\u73b0\u539f\u6765\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u662f\u6ca1\u6709\u638c\u63e1\u597d\u3002\u4eca\u5929golang\u5b66\u4e60\u7f51\u5c31\u6574\u7406\u5206\u4eab\u300aUnable&nbsp;to&nbsp;connect&nbsp;to&nbsp;Redis\u65e0\u6cd5\u8fde\u63a5\u5230Redis\u89e3\u51b3\u7684\u5168\u8fc7\u7a0b\u300b\uff0c\u804a\u804a\u65e0\u6cd5\u8fde\u63a5Redis\u3001unable\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u6b63\u5728\u52aa\u529b\u8d5a\u94b1\u7684\u4f60\u3002<\/p>\n<h2>\u9879\u76ee\u573a\u666f\uff1a<\/h2>\n<blockquote>\n<p>\u63d0\u793a\uff1a\u8fd9\u91cc\u7b80\u8ff0\u9879\u76ee\u76f8\u5173\u80cc\u666f\uff1a<\/p>\n<\/blockquote>\n<p>\u5728\u67d0\u4e2a\u9879\u76ee\u4e2d\u7684\u63d0\u4ea4\u6309\u94ae\u4e0d\u597d\u7528<\/p>\n<pre>org.springframework.data.redis.RedisConnectionFailureException: \nUnable to connect to Redis; \nnested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1\/\n   \n    :6379\n\n   <\/pre>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230513\/1683948613645f044557f27.jpg1683948613645f044557f3a.jpg\" class=\"aligncenter\"><\/p>\n<h2>\u5b8c\u6574\u7684\u9879\u76ee\u62a5\u9519\u4fe1\u606f\uff1a<\/h2>\n<blockquote>\n<p>org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1\/ :6379 <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1092) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1065) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:865) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:340) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:132) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:95) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:82) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:211) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:53) <br \/>&nbsp;&nbsp; &nbsp;at com.wuyue.travel.service.HotelService.add(HotelService.java:60) <br \/>&nbsp;&nbsp; &nbsp;at com.wuyue.travel.service.HotelService$$FastClassBySpringCGLIB$$577547fe.invoke( ) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) <br \/>&nbsp;&nbsp; &nbsp;at com.wuyue.travel.service.HotelService$$EnhancerBySpringCGLIB$$af4f4c1f.add( ) <br \/>&nbsp;&nbsp; &nbsp;at com.wuyue.travel.controller.admin.HotelController.add(HotelController.java:65) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/java.lang.reflect.Method.invoke(Method.java:577) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) <br \/>&nbsp;&nbsp; &nbsp;at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) <br \/>&nbsp;&nbsp; &nbsp;at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:74) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:357) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) <br \/>&nbsp;&nbsp; &nbsp;at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/java.lang.Thread.run(Thread.java:833) <br \/>Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1\/ :6379 <br \/>&nbsp;&nbsp; &nbsp;at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78) <br \/>&nbsp;&nbsp; &nbsp;at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56) <br \/>&nbsp;&nbsp; &nbsp;at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:234) <br \/>&nbsp;&nbsp; &nbsp;at io.lettuce.core.RedisClient.connect(RedisClient.java:204) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:113) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/java.util.Optional.orElseGet(Optional.java:364) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:113) <br \/>&nbsp;&nbsp; &nbsp;at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1085) <br \/>&nbsp;&nbsp; &nbsp;&#8230; 103 more <br \/>Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: \/127.0.0.1:6379 <br \/>&nbsp;&nbsp; &nbsp;at java.base\/sun.nio.ch.Net.pollConnect(Native Method) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/sun.nio.ch.Net.pollConnectNow(Net.java:672) <br \/>&nbsp;&nbsp; &nbsp;at java.base\/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:636) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897) <br \/>&nbsp;&nbsp; &nbsp;at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) <br \/>&nbsp;&nbsp; &nbsp;&#8230; 1 more <br \/>Caused by: java.net.ConnectException: Connection refused: no further information <br \/>&nbsp;&nbsp; &nbsp;&#8230; 12 more <\/p>\n<\/blockquote>\n<h2>\u95ee\u9898\u63cf\u8ff0\uff1a<\/h2>\n<blockquote>\n<p>\u63d0\u793a\uff1a\u8fd9\u91cc\u63cf\u8ff0\u9879\u76ee\u4e2d\u9047\u5230\u7684\u95ee\u9898\uff1a<\/p>\n<\/blockquote>\n<p>\u5728\u67d0\u4e2a\u9879\u76ee\u4e2d\u6dfb\u52a0\u6309\u94ae\u4e00\u76f4\u663e\u793a\u6267\u884c\u51fa\u9519<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230513\/1683948613645f044583bb4.jpg1683948613645f044583bcb.png\" class=\"aligncenter\"><\/p>\n<p>\u4e00\u5f00\u59cb\u60f3\u7684\u662f\u4ee3\u7801\u95ee\u9898\uff0c\u4e8e\u662f\u7ffb\u770b\u5404\u5c42\u4ee3\u7801\uff1a<\/p>\n<p>\u9996\u5148\u770b\u9875\u9762\uff1a<\/p>\n<pre><\/pre>\n<p>Controller\u5c42\u4ee3\u7801<\/p>\n<pre>\t\/**\n\t * \u589e\u52a0\n\t * @param hotel\n\t *\/\n\t@ResponseBody\n\t@RequestMapping(method=RequestMethod.POST)\n\tpublic Result add(@RequestBody Hotel hotel){\n\t\thotelService.add(hotel);\n\t\treturn new Result(true,StatusCode.OK,\"\u589e\u52a0\u6210\u529f\");\n\t}\n<\/pre>\n<p>Dao\u5c42\u6570\u636e\u8bbf\u95ee\u63a5\u53e3<\/p>\n<pre>public interface HotelDao extends JpaRepository\n   \n    ,JpaSpecificationExecutor\n    \n     { List\n     \n       findByAddrLike(String addr); } \n     \n    \n   <\/pre>\n<p>Service\u5c42\u4ee3\u7801<\/p>\n<pre>\t\/**\n\t * \u589e\u52a0\n\t * @param hotel\n\t *\/\n\tpublic void add(Hotel hotel) {\n\t\thotel.setId( idWorker.nextId()+\"\" );\n\t\t\/\/\u53d6\u5230\u7f13\u5b58\u4e2d\u7684\u6587\u4ef6url\n\t\tString fileurl = (String) redisTemplate.opsForValue().get(\"fileurl\");\n\n\t\thotel.setImg(\"https:\/\/travel031.oss-cn-qingdao.aliyuncs.com\/\"+fileurl);\n\t\thotelDao.save(hotel);\n\t}\n<\/pre>\n<p>\u5176\u5b9e\u8fd9\u4e00\u8def\u770b\u8fc7\u6765\u6ca1\u53d1\u73b0\u5565\u95ee\u9898\uff0c\u57fa\u672c\u4e0a\u662f\u8c01\u4e5f\u4e0d\u4f1a\u89c9\u5f97\u4ee3\u7801\u6709\u95ee\u9898<\/p>\n<h2>\u539f\u56e0\u5206\u6790\uff1a<\/h2>\n<blockquote>\n<p>\u63d0\u793a\uff1aUnable to connect to Redis<\/p>\n<\/blockquote>\n<p>\u8fd9\u610f\u601d\u662f\u8bf4\u65e0\u6cd5\u8fde\u63a5\u5230Redis<\/p>\n<p>\u5f53\u65f6\u662f\u770b\u5b8c\u4ee3\u7801\u89c9\u5f97\u6ca1\u95ee\u9898\u53c8\u53bbF12\u68c0\u67e5\u9875\u9762\uff0c\u5f53\u7136\u6211\u8fd8\u662f\u6ca1\u770b\u51fa\u5565\u95ee\u9898<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230513\/1683948613645f0445ab269.jpg1683948613645f0445ab27e.jpg\" class=\"aligncenter\"><\/p>\n<h2>\u89e3\u51b3\u65b9\u6848\uff1a<\/h2>\n<blockquote>\n<p>\u63d0\u793a\uff1a\u7f3a\u5c11Redis\u73af\u5883<\/p>\n<\/blockquote>\n<p>\u6700\u540e\u6709\u5e78\u5f97\u5230\u4e00\u4f4d\u5927\u4f6c\u5e2e\u52a9\uff0c\u4ed6\u544a\u8bc9\u6211\u662f\u7f3a\u5c11\u73af\u5883<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230513\/1683948613645f0445cc8ca.jpg1683948613645f0445cc8df.png\" class=\"aligncenter\"><\/p>\n<p>\u6700\u540e\u8fd0\u884c\u6210\u529f\uff01<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230513\/1683948613645f0445ec0c7.jpg1683948613645f0445ec0da.png\" class=\"aligncenter\"><\/p>\n<p>\u5728\u7ba1\u7406\u5458\u540e\u53f0\u5217\u8868\u4e2d\u4e5f\u53ef\u4ee5\u770b\u5230\u6570\u636e<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20230513\/1683948614645f04461b31e.jpg1683948614645f04461b339.jpg\" class=\"aligncenter\"><\/p>\n<h2>\u603b\u7ed3&nbsp;<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>Unable&nbsp;to&#038;n&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-201827","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201827","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=201827"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/201827\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=201827"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=201827"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=201827"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}