繁体   English   中英

Maven:无法将资源复制到远程目录

[英]Maven : Not able to copy resources to remote dir

我在用 :

  • openjdk版本“ 11.0.1” 2018-10-16
  • Apache Maven 3.6.0构建我的项目。

预计将3个资源文件从我正在编译的服务器复制到要复制资源文件的服务器。预期方式:

  • 从本地target / classes / env / $ {current_env} _context.xml将context.xml复制到/online/sand/pps/apache-tomcat-9.0.8/webapps/pps/META-INF
  • 从本地目标/类/env/${current_env}_application.properties将application.properties复制到/online/sand/pps/apache-tomcat-9.0.8/webapps/pps/WEB-INF/classes
  • 从本地target / classes / env / $ {current_env} _promote_servers.properties将promote_servers.properties复制到/online/sand/pps/apache-tomcat-9.0.8/webapps/pps/WEB-INF/classes

因此,我在pom.xml中将配置文件设置为:

<profile>
    <id>dev</id>
    <activation/>
    <properties>
        <INSTALL_MACHINE_LIST>dc1uoappptl01.patamoc-us.com</INSTALL_MACHINE_LIST>
        <COPY_MODE>sftp</COPY_MODE>
        <FTP_USERNAME>theusr</FTP_USERNAME>
        <FTP_PASSWORD>pswd</FTP_PASSWORD>
        <project_lib>/online/sand/pps/apache-tomcat-9.0.8/webapps</project_lib>
    </properties>
</profile>

复制资源,我用过:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <phase>install</phase>
            <configuration>
                <target>
                    <copy file="${project.build.directory}/classes/env/${current_env}_context.xml"
                          tofile="${project_lib}/pps/META-INF/context.xml"
                          overwrite="true"/>
                    <copy file="${project.build.directory}/classes/env/${current_env}_application.properties"
                          tofile="${project_lib}/pps/WEB-INF/classes/application.properties"
                          overwrite="true"/>
                    <copy file="${project.build.directory}/classes/env/${current_env}_promote_servers.properties"
                          tofile="${project_lib}/pps/WEB-INF/classes/promote_servers.properties"
                          overwrite="true"/>
                </target>

            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我的.war文件被stfp定位到正确的位置。 但是,资源文件不是。 我已经检查了目录权限是否在应该复制文件的远程目录中。 maven安装的日志文件显示资源已复制到上述目录,安装成功。

对我想念的东西有任何想法吗? 我应该为资源复制部分使用其他插件吗?

我的第一个猜测是,复制文件的生命周期阶段为时已晚(或紧随实际资源的sftp之后),但为了证明您还应该发布复制sftp的目标。

您可以尝试简单地更改

<executions>
        <execution>
            <phase>install</phase>

<executions>
        <execution>
            <phase>package</phase>

所以它处于早期阶段...请参阅https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM