简体   繁体   English

Spring-boot Restful Web Service连接到ftp服务器

[英]Spring-boot restful web service connect to ftp server

Firstly , I am really new to spring framework and java. 首先,我对Spring框架和Java真的很陌生。

I have the following, FTP server with subdirectory containing files. 我有以下FTP服务器,其子目录包含文件。

I want to make getAll / getOne request to the server and also a process method where I will do asynchronous processing of a file and save it to a new subdirectory and notify client once processing complete. 我想向服务器发出getAll / getOne请求,并且还要向我提出一个处理方法,在该方法中,我将对文件进行异步处理并将其保存到新的子目录中,并在处理完成后通知客户端。

So far I have managed to make GET / POST / DELETE requests to hard coded entities and display this in browser, also got similar functionality using embedded derby server. 到目前为止,我已经设法向硬编码实体发出GET / POST / DELETE请求并将其显示在浏览器中,并且使用嵌入式derby服务器也获得了类似的功能。 Have model with constructor, getters and setters, created mappings to URI in my controller which calls my services to complete the request. 在构造器,getter和setter的模型中,在控制器中创建到URI的映射,该映射调用我的服务以完成请求。

I'm struggling to figure out where do I implement the code to actually connect to the ftp server and how i do the processing asynchronously on the server itself. 我正在努力弄清楚我在哪里实现代码以实际连接到ftp服务器,以及如何在服务器本身上进行异步处理。

Any link to resources or pseudo code to help me understand would be amazing, spring docs are quite complicated for my level. 任何可以帮助我理解的资源或伪代码链接都将是惊人的,对于我的水平而言,spring文档非常复杂。 I couldn't find any simple(ish) examples to help me understand. 我找不到任何简单的示例来帮助我理解。

Thanks 谢谢

Create a FtpService class and annotate it with @Service. 创建一个FtpService类,并使用@Service对其进行注释。 create a connect method inside it. 在其中创建一个connect方法。

in the main method use the ftp service to connect to the ftp 在主要方法中,使用ftp服务连接到ftp

FtpService ftpService = context.getBean(FtpService.class);
ftpService.connect();

you can read about the @Async annotation that can make the process of the recieved files work asynchronously 您可以阅读有关@Async批注的信息,该批注可以使接收到的文件的过程异步运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM