zoukankan      html  css  js  c++  java
  • maven占位符$变量无法替换

    问题:

    maven多module开发过程中,父module继承了

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
    <relativePath/>
    </parent>

    现在想实现配置文件的多环境运行,比如有application-sit.yml,application-uat.yml,想在application.yml文件中通过变量env控制不同的环境使用不同的配置文件,
    但是打包的时候发现怎么都替换不了,打包的命令:mvn clean package -DskipTests=true -Denv=uat 或者mvn clean package -DskipTests=true -Denv=sit,
    最后打完包application.yml还是如下
    spring:
    profiles:
    active: ${env}

    解决办法:
    加上标红的那句话
    <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <configuration>
    <encoding>utf-8</encoding>
    <useDefaultDelimiters>true</useDefaultDelimiters>
    </configuration>
    </plugin>

    原因:
    spring-boot为了保护application.yml和application.properties,修改了默认的占位符${...}为@...@,受影响的应该是spring boot 1.3.0以上的版本,
    加上那句表示使用默认的占位符
  • 相关阅读:
    前后端微服务联调
    Rancher搭建ES容器集群
    Rancher解决磁盘占满异常
    Rancher搭建Redis主从集群
    Rancher搭建NFS持久存储
    Linux普通用户管理
    Rancher部署mysql8
    Delegate背后的秘密
    Java——反射
    redis 操作命令
  • 原文地址:https://www.cnblogs.com/muzhao/p/8340331.html
Copyright © 2011-2022 走看看