[英]exclude file from maven's resource directory
I am using maven for my spring boot application(1.5 version). 我正在将Maven用于我的Spring Boot应用程序(1.5版本)。 There are some files in src/main/resources
like abc.properties
, app.json
. src/main/resources
有一些文件,例如abc.properties
, app.json
。 Below are some pointer what i want to achieve. 以下是我要实现的一些指针。
I looked at related answers on SO but none matches my case. 我在SO上查看了相关的答案,但没有一个与我的情况相符。 Any suggestion? 有什么建议吗?
you can use the resouce tag in maven pom file: 您可以在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>
For more informations see: https://maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html 有关更多信息,请参见: https : //maven.apache.org/plugins/maven-resources-plugin/examples/include-exclude.html
My understanding is 我的理解是
The way I used to do is: 我以前做的方法是:
src/main/appconfig/
为此类资源创建一个单独的目录,例如src/main/appconfig/
testResource
in POM. When I use Eclipse + M2E, testResource
s will be added as source folder. Not sure how IntelliJ though) 在IDE中,手动将此目录添加为源文件夹(我通常将其放在POM的testResource
中。当我使用Eclipse + M2E时, testResource
s将被添加为源文件夹。虽然不确定IntelliJ的方式) For point 2, I used to do it slightly differently. 对于第2点,我过去所做的略有不同。 Instead of excluding, I will include in the result JAR but in a separate directory (eg appconfig-template), so that people using the application can take this as reference to configure their environment. 除了将其排除在外,我还将在结果JAR中包括一个单独的目录(例如,appconfig-template),以便使用该应用程序的人可以以此为参考来配置其环境。
An alternative of 3 is: create a separate profile which include appconfig
as resource
. 3的替代选择是:创建一个单独的配置文件,其中将appconfig
作为resource
。 Use this profile only for your IDE setup but not building your artifact. 仅将此概要文件用于IDE设置,而不能构建工件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.