maven resource 覆盖配置使用

maven resource 插件可以对于resource 进行处理,比如合并,copy,有一种比较常见的用法是进行覆盖
比如我们基于配置插件,在resource 阶段将依赖其他配置中心或者repo 的配置文件合并并覆盖到我们的构建包中

参考配置

  • 标准插件配置
 
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <executions>
      <execution>
          <id>Copy  target static folder</id>
          <phase>process-resources</phase>
          <goals>
              <goal>copy-resources</goal>
          </goals>
          <configuration>
              <outputDirectory>${project.build.outputDirectory}/public</outputDirectory>
              <overwrite>true</overwrite> // 此命令比较重要
              <resources>
                  <resource>
                      <directory>web/dist</directory>
                      <filtering>false</filtering>
                  </resource>
              </resources>
          </configuration>
      </execution>
  </executions>
</plugin>
  • 基于properties 配置
<maven.resources.overwrite>true</maven.resources.overwrite>

一种参考玩法

将不同环境的配置放在git repo 或者config 中心中,对于构建基于jenkins 使用maven 的resource 插件可以将配置进行合并,然后打包,对于基于容器的
可以基于jib-maven-plugin 实现不依赖docker engine 的镜像构建

 

 

参考资料

https://maven.apache.org/plugins/maven-resources-plugin/copy-resources-mojo.html
https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin

posted on   荣锋亮  阅读(517)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2020-10-12 关于drill http存储插件http 超时的一些说明
2020-10-12 tds-fdw PostgreSQL said: DB-Library error: DB #: 20002, DB Msg: Adaptive Server connection failed, OS #: 0, OS Msg: Success, Level: 9 问题解决.md
2018-10-12 一个不错的nomad raw_exec && docker 运行例子(集成访问网关)
2017-10-12 devops 几个方便的工具
2017-10-12 web 模板引擎

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示