日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【maven插件】maven-resources-plugin 启用 Filter 时,需要过滤的文件和不需要过滤的文件混在一起该怎么办?

發布時間:2024/9/19 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【maven插件】maven-resources-plugin 启用 Filter 时,需要过滤的文件和不需要过滤的文件混在一起该怎么办? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

前言

  • Apache Maven 3.5.0
  • OS: Windows 7, v.6.1, x86_64 / win32
  • org.apache.maven.plugins:maven-resources-plugin.version:3.1.0
  • http://maven.apache.org/plugins/maven-resources-plugin//index.html

啟用 Filter

參考這里:https://blog.csdn.net/sayyy/article/details/114889238
或者,參考這里:http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

需要過濾的文件和不需要過濾的文件混在一起該怎么辦?

方法1

同一個目錄需要過濾的文件加一次配置文件,不需要過濾的文件加一次配置文件。

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>test</groupId><artifactId>test</artifactId><version>0.0.1-SNAPSHOT</version><build><plugins><plugin><artifactId>maven-resources-plugin</artifactId><configuration><resources><resource><directory>src/main/resources</directory><filtering>true</filtering><includes><include>application.yml</include></includes></resource><resource><directory>src/main/resources</directory><filtering>false</filtering><excludes><exclude>application.yml</exclude></excludes></resource></resources></configuration></plugin> </plugins></build> </project>

ps:這個方法有后遺癥。如需要像下面這樣寫時,會執行出錯:

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>test</groupId><artifactId>test</artifactId><version>0.0.1-SNAPSHOT</version><build><plugins><plugin><artifactId>maven-resources-plugin</artifactId><configuration><resources><resource><directory>src/main/resources</directory><filtering>true</filtering><includes><include>application.yml</include></includes></resource><resource><directory>src/main/resources</directory><filtering>false</filtering><excludes><exclude>application.yml</exclude></excludes></resource></resources></configuration><executions><execution><id>copy-resources</id><phase>package</phase><goals><goal>copy-resources</goal></goals><configuration><resources><resource><directory>src/main/resources</directory><filtering>false</filtering><includes><include>application.yml</include><include>application-druid.yml</include><include>logback.yml</include></includes></resource></resources><outputDirectory>${basedir}/target</outputDirectory></configuration></execution></executions></plugin></plugins></build> </project>

方法2

maven官方示例(http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html)給出的方法:將需要過濾的文件和不需要過濾的文件分開放,即不要放到一個文件夾下。

總結

以上是生活随笔為你收集整理的【maven插件】maven-resources-plugin 启用 Filter 时,需要过滤的文件和不需要过滤的文件混在一起该怎么办?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。