[英]Apache Mina SFTP SftpSubsystem.Factory()
I am trying to setup a simple SFTP server using Apache Mine SSHD v1.2.0 .我正在尝试使用Apache Mine SSHD v1.2.0设置一个简单的 SFTP 服务器。
I have looked at several examples on the web Eg here , here and here .我在网上看过几个例子,例如这里、 这里和这里。
However they all have the same line in common which I cannot get NetBeans to resolve.但是它们都具有共同的同一行,我不能让NetBeans中的决心。 NetBeans tells me that it cannot find Factory
in SftpSubsystem
. NetBeans 告诉我它在SftpSubsystem
找不到Factory
。 The line in question looks as follows:有问题的行如下所示:
sftpServer.setSubsystemFactories (
Arrays. <NamedFactory <Command >> asList (new SftpSubsystem.Factory ()));
My main
looks something like the following:我的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);
What am I missing?我错过了什么? I simply want to connect to a dummy SFTP server and list some directories and upload a file or two.我只想连接到一个虚拟的 SFTP 服务器并列出一些目录并上传一两个文件。 The thing is that I want to do this from inside an existing java application.问题是我想从现有的 Java 应用程序内部执行此操作。
In recent versions of Apache SSHD, it's SftpSubsystemFactory
:在 Apache SSHD 的最新版本中,它是SftpSubsystemFactory
:
sftpServer.setSubsystemFactories(
Arrays.<NamedFactory<Command>>asList(new SftpSubsystemFactory()));
I'm using version 2.6.0, and now you don't need to typecast.我使用的是 2.6.0 版,现在您不需要进行类型转换。 You can simply say:你可以简单地说:
sftpServer.setSubsystemFactories(Arrays.asList(new SftpSubsystemFactory()));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.