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需要进行替换

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

    方法二:二 + 三  结合使用

    个人推荐 二 + 三  结合使用

    
    

  • 相关阅读:
    为什么 执行typeof null时会返回字符串“object”?
    vue init webpack-simple 模板中全局引入Jquery正确使用方法 可保jQuery插件正常使用
    掘金文章图片弹出放大缩小效果
    神奇的CSS3混合模式转载
    随笔
    vue-cli 项目中绝对路径引用的相关资源 npm run build 后 打开页面报404错误
    软件工程期末展示材料——RUC自习助手
    RUC自习助手_用户手册
    【声明】RUC自习助手APP(Android版)已上线,可下载
    RUC自习助手_测试文档
  • 原文地址:https://www.cnblogs.com/daixianjun/p/maven-filter.html
Copyright © 2011-2022 走看看