2
我想用Apache Mine SSHD v1.2.0设置一个简单的SFTP服务器。Apache Mina SFTP SftpSubsystem.Factory()
我已经看过网上的几个例子,例如: here,here和here。
但是,他们所有都有共同的行,我不能让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应用程序中执行此操作。
谢谢先进。
谢谢。我不知道为什么我找不到那个,但用你提供的那条线替换我的问题。 – AcidHawk