spring - 如何在spring boot application.yml中同时配置mongodb和postgres?
问题描述
我们有spring boot项目,我们需要在其中使用mongo和postgres,但我认为配置mongo和postgres详细信息applicaiton.yml失败,在我配置的下面,谁能帮我
spring:
profiles: stage
data:
mongodb:
host: mongodb-host
port: 27017
password: password
username: username
authentication-database: database
database: database
datasource:
driver-class-name: org.postgresql.Driver
url: postgres-url
username: user-name
password: password
tomcat:
validation-interval: 30000
test-on-borrow: true
validation-query: SELECT 1
当我启动我的 spring-boot 应用程序时,它无法启动并出现以下错误
Caused by: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
有人可以帮忙吗
解决方案
解决方案 1:删除spring.datasource.driver-class-name
属性
解决方案 2:将spring.datasource.url
属性重命名为spring.datasource.jdbc-url
.
对于解决方案 1,Spring Boot 将根据 spring.datasource.url 属性值找出默认的驱动程序类名称。
推荐阅读
- amazon-web-services - 将自定义域添加到 lambda 的最佳方法?
- odoo - 如何在odoo树视图onclick按钮中创建记录?
- php - 如何在服务器上使用 SSH 命令执行本地 Shell 脚本?
- angular - 角度示意图:未找到:我的示意图错误
- c# - c#中new object()到底做了什么
- python - 如何在Python中提取第一个字符
- javascript - 用 Javascript 编写代码,使用 if、else 和 prompt。
- java - 找不到参数的方法 abiFilters() [x86]
- c++ - 使用模板前向声明所有未来函数会导致歧义,而不是将声明与定义配对
- mysql - 使用 javafx 将图像上传到数据库