会话类型中的setConfig(Properties)不适用于参数(字符串,字符串)" [英] setConfig(Properties) in the type Session is not applicable for the arguments (String, String)”
问题描述
已经在这里提出了这个问题:"会话类型中的方法setConfig(Properties)不适用于参数(字符串,字符串)" 一年多以前,但没有任何答案,而我刚才也遇到了同样的问题.
This question has already been asked here: "The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String)" more than a year ago but it doesn't have any answer and I have the same problem just now.
很遗憾,我在Google上找不到任何其他内容.
Unfortunately I didn't find anything more on 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");
我的代码就这么简单,并且我收到以下消息:
My code is as simple as that and I have the following message:
会话类型中的方法setConfig(Properties)不是 适用于参数(字符串,字符串).
The method setConfig(Properties) in the type Session is not applicable for the arguments (String, String).
所以我尝试了另一种方法来做同样的事情,但是不起作用是不正常的.有人知道问题出在哪里吗?
So I tried another way to do the same thing, but it's not normal that it doesn't work. Does anyone know where is the problem ?
推荐答案
最新的JSch 0.1.55中Session.setConfig
的三个重载:
There are three overloads of the Session.setConfig
in latest JSch 0.1.55:
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中引入的!
If you do not have the third overload, you must be using some very old version of JSch. The overload was introduced in JSch 0.1.34 in 2007!
这篇关于会话类型中的setConfig(Properties)不适用于参数(字符串,字符串)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!