zoukankan      html  css  js  c++  java
  • maven filter 作用

    参考文档:https://www.cnblogs.com/1si2/p/maven_filter.html

    参考文档(springboot 下载静态文件): https://blog.csdn.net/fuyingying_/article/details/107691999

    maven 的 properties 加载顺序

    `  一. <build><filters> 中的配置

       例如下面的示例: 

    1. 1. application-${profiles.active}.properties,application.properties 在代码中需要进行代码替换需要<filtering>true</filtering>
      2. **/*.xlsx 等是静态的模板文件,不需要进行变量替换, 所以<filtering>false</filtering>
      <build>
         <resources>
            <resource>
               <directory>src/main/resources</directory>
               <filtering>true</filtering>
               <includes>
                  <include>application-${profiles.active}.properties</include>
               </includes>
            </resource>
      
            <resource>
               <directory>src/main/resources</directory>
               <filtering>false</filtering>
               <includes>
                  <include>**/*.xls</include>
                  <include>**/*.xlsx</include>
               </includes>
            </resource>
         </resources>
         <finalName>diablo-service</finalName>
      </build>

    二 pom.xml 中 <profiles.active> 进行指定

    <profiles> --  <profile> --  <properties> -- <profiles.active> 进行指定

    <profiles>
    
    		<profile>
    			<id>local</id>
    			<properties>
    				<profiles.active>local</profiles.active>
    			</properties>
    			<activation>
    				<activeByDefault>true</activeByDefault>
    			</activation>
    		</profile>
    
    		<profile>
    			<id>dev</id>
    			<properties>
    				<profiles.active>dev</profiles.active>
    			</properties>
    		</profile>
    		<!--test environment-->
    		<profile>
    			<id>test</id>
    			<properties>
    				<profiles.active>test</profiles.active>
    			</properties>
    		</profile>
    </profiles>
    

      

    三 mvn -Dproperty=value 中定义的 property

    相同 key 的 property,以最后一个文件中的配置为最终配置。

    方法一: 一 + 三结合使用

    作用: 主要是使用不同环境, application-${profiles.active}.properties 里面的变量profiles.active需要进行替换

    有些不需要替换的静态模板文件(二进制文件),不需要加入。 加入的话, 会产生乱码

    方法二:二 + 三  结合使用

    个人推荐 二 + 三  结合使用

    
    

  • 相关阅读:
    编译 出错
    关于工程思维
    关于大屏拼接方案 触摸屏 红外 和 电容屏
    爱宝A-1180热转印条码打印机 打印乱码,对不齐的问题
    制作 企业微场景 邀请函
    《七年就是一辈子》 逻辑思维 互联网 得到
    Python妙用re.sub分析正则表达式匹配过程
    第11.25节 Python正则表达式编译re.compile及正则对象使用
    Python正则表达式书写容易碰到的陷阱:W*和W*?匹配过程遇到的问题
    Python正则表达式W+和W*匹配过程的深入分析
  • 原文地址:https://www.cnblogs.com/daixianjun/p/maven-filter.html
Copyright © 2011-2022 走看看