为了账号安全,请及时绑定邮箱和手机立即绑定

使用 mariaDB 在 Spring-Boot 中实现多个数据库

使用 mariaDB 在 Spring-Boot 中实现多个数据库

www说 2021-09-12 19:58:04
我需要知道从多个数据库访问存储库和实体类的简单步骤。例如:我有用户表DB1和电子邮件在DB2必须从单一的服务请求访问。数据库 1spring.datasource.url = jdbc:mysql://localhost:3306/dbName1?useSSL=falsespring.datasource.username = userspring.datasource.password = passwordspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialectspring.jpa.hibernate.ddl-auto = update数据库 2spring.datasource.url = jdbc:mysql://localhost:3306/dbName2?useSSL=falsespring.datasource.username = userspring.datasource.password = passwordspring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect其他属性spring.jpa.properties.hibernate.jdbc.batch_size=20spring.jpa.properties.hibernate.order_inserts=truespring.jpa.properties.hibernate.order_updates=truespring.jpa.properties.hibernate.jdbc.batch_versioned_data=truespring.servlet.multipart.max-file-size=100MB spring.servlet.multipart.max-request-size=100MB
查看完整描述

3 回答

?
牛魔王的故事

TA贡献1830条经验 获得超3个赞

(不是直接回答。)


如果您将使用普通英语以外的文本,请考虑以下设置:


休眠 XML:


<property name="hibernate.connection.CharSet">utf8mb4</property>

<property name="hibernate.connection.characterEncoding">UTF-8</property>

<property name="hibernate.connection.useUnicode">true</property>

连接网址:


db.url=jdbc:mysql://localhost:3306/db_name?useUnicode=true&character_set_server=utf8mb4


查看完整回答
反对 回复 2021-09-12
?
米脂

TA贡献1836条经验 获得超3个赞

@Table(name="tablename", catalog="db2")

为我工作


查看完整回答
反对 回复 2021-09-12
  • 3 回答
  • 0 关注
  • 294 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信