properties,yml 文件讀取 pom.xml 文件變量


pom.xml 文件配置內容:

<profiles>
        <profile>
            <id>dev</id>
            <properties>
                <activatedProperties>dev</activatedProperties>
            </properties>
               <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <activatedProperties>test</activatedProperties>
            </properties>
        </profile>
        <profile>
            <id>prod</id>
            <properties>
                <activatedProperties>prod</activatedProperties>
            </properties>
        </profile>
    </profiles>

yml配置文件讀取pom.xml文件中的變量 

'@activatedProperties@' 就可以動態讀取.xml中激活的配置文件級別

spring:
  application:
    name: sky-ads-marketing
  mvc:
    throw-exception-if-no-handler-found: true
  resources:
    add-mappings: false
  profiles:
    active: '@activatedProperties@'

properties配置文件讀取pom.xml文件中的變量 跟上面yml讀取一樣

@activatedProperties@ 這樣就可以讀取到了

#配置總開關
dep=@activatedProperties@
 
# 調度中心部署跟地址 [選填]:如調度中心集群部署存在多個地址則用逗號分隔。
# 執行器將會使用該地址進行"執行器心跳注冊""任務結果回調";為空則關閉自動注冊;
dev.addresses=https://127.0.0.1:8080/xxl-job-admin
test.addresses=https://127.0.0.1:8080/xxl-job-admin
prod.addresses=https://127.0.0.1:8080/xxl-job-admin
 
xxljob.admin_addresses=${${dep}.addresses}

properties 配置文件讀取自己內部的變量用:

${變量名稱}

就可以讀取到本身內部定義的變量。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM