日期:2014-05-16  浏览次数:20877 次

apache FTP server 无法登陆
从http://mina.apache.org/ftpserver/downloads.html下载的Apache FtpServer 1.0.5 Release 解压后,运行。网页中输入ftp://localhost  提示输入账号密码,怎么也登陆不上!

因为默认的ftpd.bat 并未读取配置文件。
将ftpd.bat res/conf/ftpd-typical.xml保存为myftpd.bat,来将配置文件参数传入,执行该文件后就可以了。

在java程序中嵌入该服务器,新建java工程,并将apache-ftpserver-1.0.5\common\lib 下的包加载进来,common\classes下的log4j.properties加到src目录下,apache-ftpserver-1.0.5\res放到工程目录下;

FtpServerFactory serverFactory = new FtpServerFactory();
FtpServer server = serverFactory.createServer();

// start the server
server.start();

此时也还不可以,因为也没读配置文件,加入下面代码:

PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
userManagerFactory.setFile(new File("此处是users.properties的路径"));

运行后服务就开启了!