2012-07-29 105 views
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(); 



} 

} 

我試圖運行此代碼,但我得到這個錯誤Apache MINA FTP服務器,如何?

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 

這有什麼錯呢?謝謝。任何幫助將不勝感激。

回答

1

不知道米娜FTP,但編譯錯誤的任何建議你忘了添加一個罰球的主要方法...

public static void main(String[] args) throws FtpException { ... }