• yml、properties文件配置


    spring:
      datasource:
        url: jdbc:mysql://127.0.0.1:3306/wxdd?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8&useSSL=false
        driver-class-name: com.mysql.cj.jdbc.Driver
        username: root
        password: 123456
      jpa:
        show-sql: true
    
    
    server:
      #打的war包名
      context-path: /sell

    1.yml支持多文档块方式

    server:
      port: 8081
    spring:
      profiles:
        active: prod
    
    ---
    server:
      port: 8083
    spring:
      profiles: dev
    
    
    ---
    
    server:
      port: 8084
    spring:
      profiles: prod  #指定属于哪个环境

    2.properties配置文件

    properties配置文件中占位符

    1、随机数

    ${random.value}、${random.int}、${random.long}
    ${random.int(10)}、${random.int[1024,65536]}

    2、占位符获取之前配置的值,如果没有可以是用:指定默认值

    person.last-name=张三${random.uuid}
    person.age=${random.int}
    person.birth=2017/12/15
    person.boss=false
    person.maps.k1=v1
    person.maps.k2=14
    person.lists=a,b,c
    person.dog.name=${person.hello:hello}_dog   //若是前面的配置没有取到person.hello的值,则默认为hello
    person.dog.age=15

    3.配置文件加载顺序是根据文件的位置来定义的

    –file:./config/
    
    –file:./
    
    –classpath:/config/
    
    –classpath:/
    
    优先级由高到底,高优先级的配置会覆盖低优先级的配置;
    
    SpringBoot会从这四个位置全部加载主配置文件;**互补配置**;
  • 相关阅读:
    DExpose2:Windows 下窗体平铺预览
    第二章 随机变量及其分布3
    资源文件分享到QQ群共享里的方法
    第三章 多维随机变量及其分布1
    RegexBuddy
    第四章 随机变量的数字特征3
    html 表格排序
    关于微软自带的身份和角色验证
    学习中小型软件开发步骤
    学习路线图
  • 原文地址:https://www.cnblogs.com/gxlaqj/p/11656563.html
Copyright © 2020-2023  润新知