springboot集成mybatis多数据源,小驼峰配置,字符串为空判断

本文介绍了如何在SpringBoot中集成Mybatis实现多数据源,并提供了详细的配置步骤,包括POM依赖引入、YML配置、数据源配置类。此外,还分享了在Mybatis注解开发中进行字符串非空判断的方法,即通过(subType1 != "")进行检查。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

集成步骤:

步骤一:多数据源pom引入

<!-- PERSISTENCE begin -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>


<!-- connection pool -->
<!-- 阿里系的Druid依赖包 -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>${druid.version}</version>
</dependency>

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>${mysql.driver.version}</version>
</dependency>
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.2.5.jre7</version>
</dependency>
<!-- oracle driver -->
<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0.3</version>
</dependency>
<!-- PERSISTENCE end -->

步骤二:配置文件yml

# spring配置
spring:
  # 数据源配置
  datasource:
    self:
      jdbc-url: jdbc:mysql://地址:端口/vedio-big-data?allowMultiQueries=true&autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=UTF-8&useSSL=false
      username: 账号
      password: 密码
      drive
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值