maven打包动态替换配置文件的值

硅谷探秘者 2309 0 0

maven打包动态替换配置文件的值

pom文件添加
<profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profileActive>dev</profileActive>
            </properties>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <profileActive>test</profileActive>
            </properties>
        </profile>
    </profiles>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

<filtering>true</filtering>属性用来表示资源文件中的占位符是否需要被替换,true为需要替换。

例如如下配置:
spring:
  application:
    name: test
  profiles:
    active: @profileActive@

若 maven命令为:clean install -Dmaven.test.skip=true -Ptest

则:@profileActive@被替换为:test

完整:

spring:
  application:
    name: test
  profiles:
    active: test

若 maven命令为:clean install -Dmaven.test.skip=true -Pdev

则:@profileActive@被替换为:dev

完整:

spring:
  application:
    name: test
  profiles:
    active: dev

 


评论区
请写下您的评论...
暂无评论...
猜你喜欢
框架 1388 maven连同依赖jar一起plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-assembly-plugin
框架 3841 SpringBoot分离资源springboot项目时,把资源,如,静资源等分离出来,避免为了修改资源时重新。方式11.pombuildplugins
框架 7848 多么痛领悟~分离资源后运行项目,启失败数据源初始化失败~检查问题,这种情况下没有印错误日志,首先一下日志,将错误报告在控制台中印出来。resources夹下创建一个
maven 402 build plugins plugin groupIdorg.apache.maven.plugins/groupId artifactIdmaven-shade-plugin/artifactId version3.2.4/version!--使用最新版本-- executions execution phasepackage/phase goals goalshade/goal /goals
spring/springmvc 8919 springboot@RequestMappingurl请求路径(从中获取或默认)controller层
spring/springmvc 2182 yml:sys:qq_back:http://www.123.club/indexesqq_appid:1018qq_appkey:025bf1d0
jenkins,软件使用 1427 ,可以方便查找编译以及。三、源码构建选择git选项,在Credentials中点击添加按钮,添加git登录用户名和密码,或者是公钥。添加完成用户以后填写RepositoryURL(代码库
linux系统 1375 -Xmx1024m"exportPATH=$M2_HOME/bin:$PATH使生效:source/etc/profilemaven仓库:setting.xml中在各自标签中添加:mirrorida
归档
2018-11  12 2018-12  33 2019-01  28 2019-02  28 2019-03  32 2019-04  27 2019-05  33 2019-06  6 2019-07  12 2019-08  12 2019-09  21 2019-10  8 2019-11  15 2019-12  25 2020-01  9 2020-02  5 2020-03  16 2020-04  4 2020-06  1 2020-07  7 2020-08  13 2020-09  9 2020-10  5 2020-12  3 2021-01  1 2021-02  5 2021-03  7 2021-04  4 2021-05  4 2021-06  1 2021-07  7 2021-08  2 2021-09  8 2021-10  9 2021-11  16 2021-12  14 2022-01  7 2022-05  1 2022-08  3 2022-09  2 2022-10  2 2022-12  5 2023-01  3 2023-02  1 2023-03  4 2023-04  2 2023-06  3 2023-07  4 2023-08  1 2023-10  1 2024-02  1 2024-03  1 2024-04  1
标签
算法基础 linux 前端 c++ 数据结构 框架 数据库 计算机基础 储备知识 java基础 ASM 其他 深入理解java虚拟机 nginx git 消息中间件 搜索 maven redis docker dubbo vue 导入导出 软件使用 idea插件 协议 无聊的知识 jenkins springboot mqtt协议 keepalived minio mysql ensp 网络基础 xxl-job rabbitmq haproxy srs 音视频 webrtc javascript
目录
没有一个冬天不可逾越,没有一个春天不会来临。最慢的步伐不是跬步,而是徘徊,最快的脚步不是冲刺,而是坚持。