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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用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 模板引擎