【问题标题】:IntelliJ: Copy war file after buildIntelliJ:构建后复制战争文件
【发布时间】:2023-03-10 03:55:01
【问题描述】:

我正在使用 IntelliJ + Maven 生成战争文件。

战争总是在ProjectDirectory/target/projectname-version.war产生

构建过程完成后,我想将生成的war文件复制到不同的位置(类似于cp output X:/remote/tomcat_webapps/projectname.war)。

我已经尝试配置 maven 构建项目的目录(在 pom.xml 中)。但是,maven 总是删除包含文件夹及其所有内容,所以这不是一个选项。

如何自动将生成的war文件复制到其他位置?

【问题讨论】:

标签: maven intellij-idea


【解决方案1】:

您可以在 pom.xml 中修改 maven war 插件

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.6</version>
      <configuration>
        <outputDirectory>X:/remote/tomcat_webapps</outputDirectory>
      </configuration>
    </plugin>
  </plugins>
</build>

我不太确定,如果它是 outputDirectory 还是应该是 webappDirectory,就像在文档中一样

https://maven.apache.org/plugins/maven-war-plugin/usage.html

【讨论】:

  • 谢谢,这行得通。是否也可以仅为特定配置文件激活此配置? (有一个配置文件进行本地构建,另一个配置文件将其部署在服务器上)
猜你喜欢
  • 2013-12-01
  • 2016-01-18
  • 1970-01-01
  • 2018-10-30
  • 2011-03-22
  • 1970-01-01
  • 2022-01-16
  • 1970-01-01
  • 2016-04-26
相关资源
最近更新 更多