无法使用 maven-antrun-plugin 从 ftp 下载文件(检索到 0 个文件)
Unable to dowload file from ftp with maven-antrun-plugin (0 files retrieved)
我正在使用 maven-antrun-plugin 从 FTP 下载转储。
这是我的 pom.xml :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ftp</id>
<phase>package</phase>
<configuration>
<target>
<ftp action="get"
server="myserver"
remotedir="/remotedir/"
userid="anonymous"
password="anonymous"
depends="yes"
verbose="yes">
<fileset dir="${project.build.directory}">
<include name="**/*.*" />
</fileset>
</ftp>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<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>
该插件似乎可以工作,但它不会下载我的转储(“0 个文件已检索到”)。
> main:
> [ftp] Opening FTP connection to myserver
> [ftp] connected
> [ftp] logging in to FTP server
> [ftp] login succeeded
> [ftp] changing the remote directory to /remotedir/
> [ftp] getting files fileset: Setup scanner in dir /myproject/target with patternSet{ includes: [**/*.*] excludes: [] }
> [ftp] 0 files retrieved
> [ftp] disconnecting
我可以在 myserver/remotedir/ 上使用 FileZilla 下载此转储(以匿名方式)。当我故意尝试错误的 remotedir 时,它会正确地警告我(“550 无法更改目录。”)所以我猜没有连接问题。
我找到了让它起作用的方法!参考 Ant manual,我在 Ant FTP 任务中使用 passive 属性。
If you can connect but not upload or download, try setting the passive attribute to true to use the existing (open) channel, instead of having the server try to set up a new connection.
这是 pom.xml 中的内容:
<target>
<ftp action="get"
server="myserver"
remotedir="/remotedir"
userid="anonymous"
password="anonymous"
verbose="yes"
passive="yes">
<fileset dir="${project.build.directory}">
<include name="**/*.*"/>
</fileset>
</ftp>
</target>
我正在使用 maven-antrun-plugin 从 FTP 下载转储。
这是我的 pom.xml :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>ftp</id>
<phase>package</phase>
<configuration>
<target>
<ftp action="get"
server="myserver"
remotedir="/remotedir/"
userid="anonymous"
password="anonymous"
depends="yes"
verbose="yes">
<fileset dir="${project.build.directory}">
<include name="**/*.*" />
</fileset>
</ftp>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<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>
该插件似乎可以工作,但它不会下载我的转储(“0 个文件已检索到”)。
> main:
> [ftp] Opening FTP connection to myserver
> [ftp] connected
> [ftp] logging in to FTP server
> [ftp] login succeeded
> [ftp] changing the remote directory to /remotedir/
> [ftp] getting files fileset: Setup scanner in dir /myproject/target with patternSet{ includes: [**/*.*] excludes: [] }
> [ftp] 0 files retrieved
> [ftp] disconnecting
我可以在 myserver/remotedir/ 上使用 FileZilla 下载此转储(以匿名方式)。当我故意尝试错误的 remotedir 时,它会正确地警告我(“550 无法更改目录。”)所以我猜没有连接问题。
我找到了让它起作用的方法!参考 Ant manual,我在 Ant FTP 任务中使用 passive 属性。
If you can connect but not upload or download, try setting the passive attribute to true to use the existing (open) channel, instead of having the server try to set up a new connection.
这是 pom.xml 中的内容:
<target>
<ftp action="get"
server="myserver"
remotedir="/remotedir"
userid="anonymous"
password="anonymous"
verbose="yes"
passive="yes">
<fileset dir="${project.build.directory}">
<include name="**/*.*"/>
</fileset>
</ftp>
</target>