SFTP问题1:使用SFTP上传文件报错com.jcraft.jsch.JSchException: java.net.ConnectException: Connection refused: co

问题描述

调用文件上传接口是报连接异常

com.jcraft.jsch.JSchException: java.net.ConnectException: 拒绝连接
        at com.jcraft.jsch.Util.createSocket(Util.java:344)
        at com.jcraft.jsch.Session.connect(Session.java:194)
        at com.jcraft.jsch.Session.connect(Session.java:162)
        at com.sitech.smartcity.util.util.SftpUtil.connect(SftpUtil.java:118)
        at com.sitech.smartcity.rest.qiannan.shulvtong.SLTApiController.upLoadPic(SLTApiController.java:266)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:

验证

报错原因

端口不通

解决

修改端口

主机连接不上改ip或端口 ,linux的sftp端口大多数都是22

posted @ 2022-08-17 15:32  可归  阅读(2752)  评论(0编辑  收藏  举报