gpt4 book ai didi

java - 从maven的资源目录中排除文件

转载 作者:行者123 更新时间:2023-12-02 13:12:56 24 4
gpt4 key购买 nike

我正在为我的 Spring Boot 应用程序(1.5 版本)使用 Maven。 src/main/resources 中有一些文件,例如 abc.propertiesapp.json。以下是我想要实现的一些目标。

  1. 排除这些文件进入 jar。
  2. 当我通过 intellij 运行我的应用程序时,这些文件应该在类路径中可用。

我查看了 SO 上的相关答案,但没有一个符合我的情况。有什么建议吗?

最佳答案

您可以在maven pom文件中使用resouce标签:

  <resources>
<resource>
<directory>[your directory]</directory>
<excludes>
<exclude>[non-resource file #1]</exclude>
<exclude>[non-resource file #2]</exclude>
<exclude>[non-resource file #3]</exclude>
...
<exclude>[non-resource file #n]</exclude>
</excludes>
</resource>
...
</resources>

有关更多信息,请参阅:https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html

关于java - 从maven的资源目录中排除文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43886661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com