【发布时间】:2019-06-20 16:20:50
【问题描述】:
我正在使用:
- openjdk 版本“11.0.1”2018-10-16
- Apache Maven 3.6.0 建立我的项目。
期望3个资源文件从我正在编译的服务器复制到要复制资源文件的服务器。预期方式:
- 将 context.xml 复制到 /online/sand/pps/apache-tomcat-9.0.8/webapps/pps/META-INF 来自本地 目标/类/env/${current_env}_context.xml
- 将 application.properties 从本地 target/classes/env/${current_env}_application.properties 复制到 /online/sand/pps/apache-tomcat-9.0.8/webapps/pps/WEB-INF/classes
- 将promote_servers.properties从本地target/classes/env/${current_env}_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安装的日志文件显示资源已经复制到上述目录,安装成功。
知道我缺少什么吗?我应该为资源复制部分使用不同的插件吗?
【问题讨论】:
标签: java maven maven-antrun-plugin