java - 将文件替换为由 mvn 包生成的 WAR 文件
问题描述
我有一个 maven 项目,我想在使用clear package
maven 命令时从源代码替换配置文件并将其替换为 WAR 中令人兴奋的一个。我试过了,但替换只发生在提取的文件夹而不是 WAR 文件中,这是我的 pom.xml
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>target/Project-xyz/classes/resources</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/java/resources/customers</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
解决方案
经过这么多试验,它通过使用
org.apache.maven.plugins
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<id>default-war</id>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp/resources/customer1/css</directory>
<targetPath>resources/css</targetPath>
</resource>
</webResources>
</configuration>
</execution>
</executions>
</plugin>
推荐阅读
- python - 远程使用 Pywinrm 的 Python 3.6
- c++ - 如何使用 nlhoman json 在 C++ 中将相同的关键 json 数据合并为一个
- javascript - 获取在 LUIS 上添加的句子
- android - 使用 recyclerview 滚动 coordinatorLayout 中的 Android 抖动错误(instagram 也有此错误)
- c++ - 何时在 C++ 中的嵌套类上使用 Pimpl 模式,反之亦然?
- javascript - 如何在异常捕获中获取数据库引用?
- botframework - Microsoft 团队免费帐户:此卡操作已禁用,因为 BOT 已被您的管理员阻止
- windows - 如何执行 ubuntu.exe 并使用一个命令导航到直接文件夹?
- google-cloud-platform - 在 GCP 上调整永久磁盘大小时,如何触发文件系统调整大小?
- ruby-on-rails - Rails:如何删除默认版本的捆绑程序?