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

硅谷探秘者 1815 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

 

猜你喜欢
框架 1190 maven连同依赖jar一起plugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-assembly-plugin
框架 3650 SpringBoot分离资源springboot项目时,把资源,如,静资源等分离出来,避免为了修改资源时重新。方式11.pombuildplugins
框架 7700 多么痛领悟~分离资源后运行项目,启失败数据源初始化失败~检查问题,这种情况下没有印错误日志,首先一下日志,将错误报告在控制台中印出来。resources夹下创建一个
spring/springmvc 8164 springboot@RequestMappingurl请求路径(从中获取或默认)controller层
spring/springmvc 1683 yml:sys:qq_back:http://www.123.club/indexesqq_appid:1018qq_appkey:025bf1d0
jenkins,软件使用 1269 ,可以方便查找编译以及。三、源码构建选择git选项,在Credentials中点击添加按钮,添加git登录用户名和密码,或者是公钥。添加完成用户以后填写RepositoryURL(代码库
linux系统 1180 -Xmx1024m"exportPATH=$M2_HOME/bin:$PATH使生效:source/etc/profilemaven仓库:setting.xml中在各自标签中添加:mirrorida
框架 1141 -warn"/appender-refref="file-error"//root/configuration不同级别日志由不同appender处理。二、application.yml日志存放目
归档
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
标签
算法基础 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
目录
没有一个冬天不可逾越,没有一个春天不会来临。最慢的步伐不是跬步,而是徘徊,最快的脚步不是冲刺,而是坚持。