java - 如何在 spring.datasource.url 中使用 2 个默认值
问题描述
spring
datasource:
url: ${DB_HOST_URI:#{jdbc:postgresql://localhost:5433}}/${PS_DB_NAME:#{ps_application}}
您好,我有上面的代码,当我尝试运行 ./gradlew bootRun 时,默认的 url 应该jdbc:postgresql://localhost:5433/ps_application
是不正确的,我收到:
14:10:28[main][ERROR]o.s.b.SpringApplication:: Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.exception.FlywaySqlException:
Unable to obtain connection from database: The connection attempt failed.
您是否知道如何拆分 URL 并最终使用具有默认值的两个变量?或对此有任何想法?
我正在使用spring boot和gradle提前谢谢!
解决方案
推荐阅读
- sql - PLSQL NOT IN ('val1','val2') 不在过程中工作
- c - 浮点数 if 语句返回负数而不是给定值
- flutter - 如何使用 Flutter 回滚到 Dart 2.10.4?
- razor - 如何使用 C# 在 2sxc 中为横幅英雄创建面包屑导航?
- javascript - React - 加载的数据能够控制台日志但未显示在 DOM 中?
- javascript - 打字稿中的 Javascript
- css - 使用 CSS 在模态内容顶部打开模态
- logstash - 日志分析后分析、异常检测和警报 - ELK
- python - 为什么我的 Python 脚本在 Power Bi 中运行时表现不同
- reactjs - 无法将道具传递给 React Router 页面组件,TS2322