【问题标题】:How to download files from ftp server using maven?如何使用 maven 从 ftp 服务器下载文件?
【发布时间】:2015-06-26 07:19:11
【问题描述】:

我想创建一个 pom.xml,它将从远程 FTP 服务器获取一些 .dmp 文件,

要访问此服务器,我有它的 URL 用户名和密码(当然只有读取权限)。

从服务器获取这些文件的最佳方式是什么?

使用 maven-ant 插件/maven 执行器/ 或任何其他我不知道的插件?

【问题讨论】:

    标签: maven maven-plugin pom.xml maven-antrun-plugin


    【解决方案1】:

    试试这个

     <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.8</version>
            <configuration>
                <target>
                    <ftp action="get"
                         server="192.168.1.1"
                         remotedir="remoteDir"
                         userid="anonymous"
                         password="anonymous">
                        <fileset dir="${project.build.directory}">
                            <include name="**/*.*"/>
                        </fileset>
                    </ftp>
                </target>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>commons-net</groupId>
                    <artifactId>commons-net</artifactId>
                    <version>1.4.1</version>
                </dependency>
                <dependency>
                    <groupId>org.apache.ant</groupId>
                    <artifactId>ant-commons-net</artifactId>
                    <version>1.8.1</version>
                </dependency>
            </dependencies>
        </plugin>
    

    你也可以看看here

    【讨论】:

    • 它有效,但由于某种原因它没有让我获得 .dmp 文件。 .txt 文件被提取得很好。
    • 检查 .dmp 文件的路径,看看它是否与上面的包含名称表达式匹配,如果不匹配,则必须相应地更改它。另请查看我在上面发布的链接。
    • 都检查过了。它没有给我一个错误它似乎被卡住了(也许它与文件大小有关)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-30
    • 1970-01-01
    • 1970-01-01
    • 2020-10-31
    相关资源
    最近更新 更多