0
import org.apache.ftpserver.config.*;
import org.apache.ftpserver.filesystem.*;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.command.*;
import org.apache.ftpserver.config.spring.*;
import org.apache.*;
import org.apache.ftpserver.impl.*;

public class ftpko {


public static void main(String[] args) {
    // TODO Auto-generated method stub
    FtpServerFactory serverFactory = new FtpServerFactory();

    ListenerFactory factory = new ListenerFactory();

    // set the port of the listener
    factory.setPort(2221);

    // replace the default listener
    serverFactory.addListener("default", factory.createListener());

    // start the server
    FtpServer server = serverFactory.createServer(); 
            server.start();



}

}

我正在尝试运行此代码,但出现此错误

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
Unhandled exception type FtpException

这是堆栈跟踪:

log4j:WARN No appenders could be found for logger        (org.apache.ftpserver.impl.DefaultFtpServerContext).
log4j:WARN Please initialize the log4j system properly

这有什么问题?谢谢。任何帮助将不胜感激。

4

1 回答 1

1

对 MINA ftp 一无所知,但编译错误表明您忘记在 main 方法中添加 throws ...

public static void main(String[] args) throws FtpException { ... }
于 2012-12-10T15:08:02.127 回答