开发者社区 问答 正文

[@徐雷frank][¥20]springboot2.0.5在已经有一个sqlserver数据源的情况的添加一个mysql数据库

环境:springboot2.0.5
JDK10
问题描述:在这个项目里面添加一个mysql数据源,主要作用是同步sqlserver中的用户表数据,
访问量不大,基本不用数据库连接池,用完之后数据连接就直接关掉。

展开
收起
晓生寒 2018-12-13 22:56:14 2370 分享 版权
1 条回答
写回答
取消 提交回答
  • 1.阿里云大学荣誉讲师, 2.MongoDB中文社区专家

    sql server数据库配置语法如下:
    spring.datasource.url=jdbc:sqlserver://localhost;databaseName=springbootdb
    spring.datasource.username=sa
    spring.datasource.password=Projects@123
    spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
    多个数据库配置语法参考:
    app.datasource.first.url=jdbc:mysql://localhost/first
    app.datasource.first.username=dbuser
    app.datasource.first.password=dbpass
    app.datasource.first.configuration.maximum-pool-size=30

    app.datasource.second.url=jdbc:mysql://localhost/second
    app.datasource.second.username=dbuser
    app.datasource.second.password=dbpass
    app.datasource.second.max-total=30
    参考Spring Boot 官方文档https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-two-datasources

    2019-07-17 23:20:52
    赞同 展开评论