Session 类型中的 setConfig(Properties) 不适用于参数 (String, String)”
setConfig(Properties) in the type Session is not applicable for the arguments (String, String)”
这里已经有人问过这个问题:"The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String)"
一年多以前,但它没有任何答案,我现在也有同样的问题。
很遗憾,我在 Google 上没有找到更多内容。
import com.jcraft.jsch.*;
import java.io.*;
import java.util.Properties
JSch jsch = new JSch();
String user = "myUserId";
String host = "myHost";
Session session = jsch.getSession(user, host, 22);
session.setConfig("StrictHostKeyChecking", "no");
我的代码就这么简单,我收到以下消息:
The method setConfig(Properties) in the type Session is not
applicable for the arguments (String, String).
所以我尝试了另一种方法来做同样的事情,但它不起作用是不正常的。有谁知道问题出在哪里?
如文档中所述,它是一个静态方法,因此它应该是 'Session',其中 Session 是 class 而不是对象会话。我希望你能理解其中的区别。
在最新的 JSch 0.1.55 中 Session.setConfig
有三个重载:
public void setConfig(java.util.Properties newconf)
public void setConfig(java.util.Hashtable newconf)
public void setConfig(String key, String value)
如果你没有第三个重载,你一定是在使用一些非常旧的 JSch 版本。重载是在 2007 年的 JSch 0.1.34 中引入的!
这里已经有人问过这个问题:"The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String)" 一年多以前,但它没有任何答案,我现在也有同样的问题。
很遗憾,我在 Google 上没有找到更多内容。
import com.jcraft.jsch.*;
import java.io.*;
import java.util.Properties
JSch jsch = new JSch();
String user = "myUserId";
String host = "myHost";
Session session = jsch.getSession(user, host, 22);
session.setConfig("StrictHostKeyChecking", "no");
我的代码就这么简单,我收到以下消息:
The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String).
所以我尝试了另一种方法来做同样的事情,但它不起作用是不正常的。有谁知道问题出在哪里?
如文档中所述,它是一个静态方法,因此它应该是 'Session',其中 Session 是 class 而不是对象会话。我希望你能理解其中的区别。
在最新的 JSch 0.1.55 中 Session.setConfig
有三个重载:
public void setConfig(java.util.Properties newconf)
public void setConfig(java.util.Hashtable newconf)
public void setConfig(String key, String value)
如果你没有第三个重载,你一定是在使用一些非常旧的 JSch 版本。重载是在 2007 年的 JSch 0.1.34 中引入的!