在 application.yml 或者 application.properties 值的位置随便写这样的语法就可以替换文本
${MYSQL_URL:192.168.0.100}
比如
datasource:type: com.alibaba.druid.pool.DruidDataSourcedriverClassName: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://${MYSQL_URL:192.168.0.100}:3306/demo?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&useServerPrepStmts=false&rewriteBatchedStatements=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=trueusername: ${MYSQL_USERNAME:root}password: ${MYSQL_PASSWORD:123456}
如果在环境变量中找的到就用环境变量,如果找不到就用冒号后面的默认值
那如果默认值里有冒号会冲突吗?