如何使用maven从ftp服务器下载文件?

时间:2015-06-26 07:19:11

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

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

访问此服务器我有它的URL用户名和密码(当前只有READ权限)。

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

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

1 个答案:

答案 0 :(得分: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