zoukankan      html  css  js  c++  java
  • Maven打包时指定对应环境的配置文件

    <!-- 
    pom文件新增==============================================
     -->
    <profiles>
    
        <profile>  
            <!-- 开发环境 -->
            <id>dev</id><!-- 编译时输入该变量-->
            <properties>  
                <environment>DEV</environment><!-- 读取配置文件时,加上对应值`DEV`(大小写皆可)-->
            </properties>  
            <activation>  
                <activeByDefault>true</activeByDefault><!-- 默认该环境配置文件-->
            </activation>
        </profile>
        <profile>  
            <!-- 测试环境 -->
            <id>dat</id>  
            <properties>  
                <environment>DAT</environment>
            </properties>  
        </profile>
        <profile>  
            <!-- 生产环境 -->
            <id>prd</id>  
            <properties>  
                <environment>PRD</environment>
            </properties>  
        </profile>
    
    </profiles>
    
    <build>
    
    
    	<resources>
            <resource>
                <directory>src/main/resources/config-${environment}</directory><!-- 配置文件从哪里读取,`environment`为上方值如:`DEV`,大小写皆可识别 -->
                <!-- <filtering>true</filtering> -->
                <targetPath>config</targetPath><!-- 配置文件放在哪里 -->
            </resource>
        </resources>
    </build>
    <!-- 
    pom文件新增==============================================
     -->
    
    

    图解:

  • 相关阅读:
    python爬虫
    绕过CDN查找网站真实IP方法收集
    拖库
    伪静态注入的总结
    国外安全网站信息收集
    python字典去重脚本
    AOP 的利器:ASM 3.0 介绍
    JDK工具
    JVM性能调优监控工具
    DMZ
  • 原文地址:https://www.cnblogs.com/jrri/p/15568419.html
Copyright © 2011-2022 走看看