我使用以下配置通过FTPS协议将文件上传到远程服务器:
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>3.0.0</version>
</extension>
</extensions>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<skip>true</skip>
<url>ftps://username:password@ip_address</url>
<fromDir>${project.build.directory}</fromDir>
<toDir>.</toDir>
</configuration>
<executions>
<execution>
<id>upload</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
</execution>
</executions>
</plugin>
如果我在url参数中仅使用FTP而不是FTPS,则目标将成功执行并将数据发送到远程服务器,但是当我出于安全原因使用FTPS时,出现以下错误:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload (default-cli) on project XXX: The parameters 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload are missing or invalid
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload are missing or invalid
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:641)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:594)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
'
我使用以下配置解决了这个问题:
Pom.xml :
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>3.0.0</version>
</extension>
</extensions>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<serverId>serverid</serverId>
<skip>true</skip>
<url>ftps://ip_address:port</url>
<fromDir>${project.build.directory}</fromDir>
<toDir>.</toDir>
</configuration>
<executions>
<execution>
<id>upload</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
</execution>
</executions>
</plugin>
设置.xml :
<server>
<id>serverid</id>
<username>XXXXXX</username>
<password>XXXXXX</password>
<configuration>
<endpointChecking>false</endpointChecking>
<securityProtocol>TLS</securityProtocol>
<implicit>true</implicit>
<passiveMode>true</passiveMode>
</configuration>
</server>
谢谢!
我无法在我的环境中测试答案,但似乎 Wagon 支持带有 FTP 提供程序的 FTPS 模式。
但是,文档指出,您应该为此将securityProtocol
配置为 FTPS,因为默认值为 TLS。
// settings.xml
<server>
<id>ftp.server.id</id>
<username>username</username>
<password>password</password>
<configuration>
....
<securityProtocol>FTPS</securityProtocol> <-- !!!
</configuration>
</server>
我最近遇到了类似的问题。就我而言,因为我的FTP服务器的证书是自签名的,所以我确实必须禁用endpointChecking
:
<endpointChecking>false</endpointChecking>
但是,Wagon FTP提供商似乎也不支持加密的数据连接。我在代码中没有看到提及
FTPSClient.execProt("P");
由于我vsftpd
作为我的FTP服务器运行,因此也有必要允许服务器端未加密的数据连接:
# vsftpd.conf
...
force_local_data_ssl=NO
就我而言,使用<implicit>
设置会适得其反,因为默认情况下vsftpd
协商端口而不是使用隐式端口。