3

我正在使用以下配置通过 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)

'

4

3 回答 3

2

我使用以下配置解决了这个问题:

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>

谢谢 !

于 2019-12-17T10:09:11.073 回答
0

我无法在我的环境中测试答案,但 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>
于 2019-12-05T07:24:01.910 回答
0

我最近遇到了类似的问题。就我而言,因为我的 FTP 服务器证书是自签名的,所以我必须禁用endpointChecking

<endpointChecking>false</endpointChecking>

但是,Wagon FTP 提供程序似乎也不支持加密数据连接。我看代码中没有提到

FTPSClient.execProt("P");

由于我vsftpd作为我的 FTP 服务器运行,因此有必要在服务器端允许未加密的数据连接:

# vsftpd.conf 
...
force_local_data_ssl=NO

就我而言,使用该<implicit>设置会适得其反,因为vsftpd默认情况下会协商端口而不是使用隐式端口。

于 2022-03-04T15:16:56.013 回答