我正在尝试使用Apache地雷SSHD v1.2.0设置一个简单的SFTP服务器。
但是,它们所有的都有相同的行,我无法让NetBeans来解决这个问题。NetBeans告诉我,它在SftpSubsystem中找不到Factory。这条线看上去如下:
sftpServer.setSubsystemFactories (
Arrays. <NamedFactory <Command >> asList (new SftpSubsystem.Factory ()));我的main看起来如下所示:
SshServer sftpServer = SshServer.setUpDefaultServer ();
sftpServer.setPort (PORT);
sftpServer.setKeyPairProvider (new SimpleGeneratorHostKeyProvider (new File("hostkey.ser")));
sftpServer.setSubsystemFactories (
Arrays. <NamedFactory <Command >> asList (new SftpSubsystem.Factory ()));
sftpServer.setPasswordAuthenticator (new PasswordAuthenticator () {
@Override
public boolean authenticate (String username, String password, ServerSession session) {
return true;
}
});
sftpServer.start ();
while(true);我遗漏了什么?我只想连接到一个虚拟的SFTP服务器,列出一些目录并上传一两个文件。问题是,我想从现有的java应用程序中执行此操作。
发布于 2017-05-08 08:59:43
在Apache的最新版本中,它是SftpSubsystemFactory
sftpServer.setSubsystemFactories(
Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory()));发布于 2021-05-23 10:49:48
我使用的是2.6.0版本,现在您不需要输入类型了。你可以简单地说:
sftpServer.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory()));https://stackoverflow.com/questions/43842937
复制相似问题