Petua: Berikut ialah penerangan ringkas tentang latar belakang berkaitan projek:
Butang hantar dalam projek tertentu tidak mudah digunakan
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/<unresolved>:6379
org.springframework.data.redis.RedisConnectionFailureException: Tidak dapat menyambung ke Redis; Pengecualian bersarang ialah io.lettuce.core.RedisConnectionException: Tidak dapat menyambung ke 127.0.0.1/
:6379
di org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.$SharedFactoryConnectionFactory$SharedLettuceConnectionFactory. :1092)
di org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1065)
at org.springdissframework.Connection. pertalian (LettuconnectionFactory.java:865)
di org.springframework.data.redis.connection.lettuce.lettuconnectionFactory.getConnection (LettuconnectionFactory.java:340) (RedisConnectionUtils.java:132)
di org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:95)
di org.springframework.data.redisnectionUtils.RedisnectionU. .java:82)
di org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:211)
at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java :184)
di org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95)
at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValue.Java )
di com.wuyue.travel.service.HotelService.add(HotelService.java:60)
at com.wuyue.travel.service.HotelService$$FastClassBySpringCGLIB$$577547fe.invoke&(&glt.
di org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
di org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invoke Join4.invoke Join di org.springframework.aop.framework.reflectivemethodinvocation.procte (reflectiveThodinvocation.java:163) Amework.Transaction. interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
di org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
. pada org.springframework.aop.framework edInterceptor. intercept(CglibAopProxy.java:688)
at com.wuyue.travel.service.HotelService$$EnhancerBySpringCGLIB$$af4f4c1f.add()
at com.Hotelcontrollerer.wuyue.ad .add(HotelController.java:65)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.inlectbase.Java.lang.reflect (Method.java:577)
di org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
di org.springframework.web.methodableHinvoke.web.methodable. hod .java:138)
di org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
.web . .RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
di org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(AquestterMapping.🎜 at java : ringframework.web.servlet .mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
di org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038>DispatcherServlet.java:1038> .springframework.web.servlet ervlet .doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.serveworkletFrameworkServlet. :908)
di javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
di org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java)
di org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java) 🎜 atjava .servlet.http.HttpServlet.service(HttpServlet.java:741)
di org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
di org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
. apache attom org. .websocket.server.WsFilter.doFilter(WsFilter.java:53)
di org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.Catalina .doFilter(ApplicationFilterChain.java:166)
di org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320)
at org.intercept.webFilteraccess.security .invoke(FilterSecurityInterceptor.java:127)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
.web. .doFilter(FilterChainProxy.java:334)
di org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119)
di org.springframework.security.web.Vir.FilterChalterChain.web.Vir.FilterChannel (FilterChainProxy.java:334)
di org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
at org.springframework.security.web.VlterChalterChainFilter(ProxyFilterChalter. .java:334)
di org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
at org.springframework.security.web.Vir.ProxyFilterChannel :334)
di org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170)
at org.springframework.FilterinProxyweb.Filter. java:334 )
di org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
di org.springframework.security.web.FilterChainProxy$VirtualFilterChain.Chain.Charles. 🎜> di org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116)
di org.springframework.security.web.FilterChainProxy$VirtualFilterChain(Java:3ChainFilter4 . .springframework.security.web.filterchainproxy $ virtualfilterchain.dofilter (filterchainproxy.java:334) G.SpringFramework .security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
di org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilter Internal(🎜 WebAsync) org .springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
di org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java: . . .springframework.java:334>) .web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
di org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
di org.filterProxyDelegate. (DelegatingFilterProxy.java:357)
di org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:270)
di org.apache.catalina.core.ApplicationjavaFilterChain.3ApplicationDolterChain. )
di org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
di org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter)<.java :99 .springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
di org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
di org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
di org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
org .springframework .filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
di org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
.calter.apache. (ApplicationFilterChain.java:166)
di org.springframework.web.filter.hiddenhtpmethodfilter.dofilterinternal (hiddenhttpmethodfilter.java:93) Estfilter.java:107 )
di org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java) : : : .springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
di org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) apache atcacore. .ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.apache. alve .java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.invoke(AuthenticatorBase.invoke) 🎜> di org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
di org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReport2Valve) java. .catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
di org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
http 1.coyoteAdapter. .service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProcessorLight.Process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$Pronection.AbstractProtocol$Pronection. )
di org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417)
di org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49 )
di java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
di java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.Java:1136)
di java.base/java.util.concurrent.ThreadPoolExecutor.Executor$Worker.run(ThreadExecutor$Worker.run(ThreadPool. )
di org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
di java.base/java.lang.Thread.run(Thread.java:833)
Disebabkan oleh: io.lettuce.core.RedisConnectionException: Tidak dapat menyambung ke 127.0.0.1/:6379
di io.lettuce.core.RedisConnectionException.create(at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:234)
at io.lettuce.core.Re (RedisClient.java:204)
di org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:113)
at java.base/java. orElseGet(Optional.java:364)
at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:113)
at org.rediscetionframework.data. LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1085)
... 103 lagi
Disebabkan oleh: io.netty.channel.AbstractChannel$AnnotatedConnectException: Maklumat lanjut: /0.21: Sambungan ditolak: /0.21 🎜> di java.base/sun.nio.ch.Net.pollConnect(Kaedah Asli)
di java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
di java. base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:636)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:583)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:500)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:462)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
... 1 more
Caused by: java.net.ConnectException: Connection refused: no further information
... 12 more
提示:这里描述项目中遇到的问题:
在某个项目中添加按钮一直显示执行出错
一开始想的是代码问题,于是翻看各层代码:
首先看页面:
<script> layui.use(['form', 'upload', 'laydate'] ,function(){ var form = layui.form ,$ = layui.jquery ,layer = layui.layer ,upload = layui.upload ,laydate = layui.laydate; //日期 laydate.render({ elem: '#date' }); //普通图片上传 var uploadInst = upload.render({ elem: '#test1' ,url: '/uploadFile' ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ $('#demo1').attr('src', result); //图片链接(base64) }); } ,done: function(res){ //如果上传失败 if(res.code > 0){ return layer.msg('上传失败'); } //上传成功 return layer.msg('上传成功'); } ,error: function(){ //演示失败状态,并实现重传 var demoText = $('#demoText'); demoText.html('<span >上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>'); demoText.find('.demo-reload').on('click', function(){ uploadInst.upload(); }); } }); //监听提交 form.on('submit(setmyinfo)', function(obj){ $.ajax({ type: "POST", url: "/hotel", data: JSON.stringify(obj.field), dataType: "json", contentType: "application/json;charset=utf-8", success: function(result) { if(result.code == 0) { //登入成功的提示 layer.msg( result.message,{ icon: 1 }); } else { layer.msg(result.message, { icon: 5 }); } } }); }); }); </script>
Controller层代码
/** * 增加 * @param hotel */ @ResponseBody @RequestMapping(method=RequestMethod.POST) public Result add(@RequestBody Hotel hotel){ hotelService.add(hotel); return new Result(true,StatusCode.OK,"增加成功"); }
Dao层数据访问接口
public interface HotelDao extends JpaRepository<Hotel,String>,JpaSpecificationExecutor<Hotel>{ List<Hotel> findByAddrLike(String addr); }
Service层代码
/** * 增加 * @param hotel */ public void add(Hotel hotel) { hotel.setId( idWorker.nextId()+"" ); //取到缓存中的文件url String fileurl = (String) redisTemplate.opsForValue().get("fileurl"); hotel.setImg("https://travel031.oss-cn-qingdao.aliyuncs.com/"+fileurl); hotelDao.save(hotel); }
其实这一路看过来没发现啥问题,基本上是谁也不会觉得代码有问题
提示:Unable to connect to Redis
这意思是说无法连接到Redis
当时是看完代码觉得没问题又去F12检查页面,当然我还是没看出啥问题????
提示:缺少Redis环境
最后运行成功!
在管理员后台列表中也可以看到数据
Atas ialah kandungan terperinci Tidak dapat menyambung ke Redis Bagaimana untuk menyelesaikan masalah Tidak dapat menyambung ke Redis. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!