springboot+mybatis多数据源mysql+oracle

一、异常错误处理:

1.jdbcUrl is required with driverClassName这行错误,一直报我的mybatis的xml文件的问题,其实并没有关系,主要原因是jdbcUrl的问题
2019-04-25 13:50:12.644 ERROR 14660 — [nio-8080-exec-1] com.zaxxer.hikari.HikariConfig : HikariPool-1 - jdbcUrl is required with driverClassName.
2019-04-25 13:50:12.654 ERROR 14660 — [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
The error may exist in class path resource [mybatis/mapper/StudentMapper3.xml]
The error may involve cn.syp.databases.mapper.mapper3.StudentMapper3.findAll3
The error occurred while executing a query
Cause: java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.] with root cause

java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.

解决方案:

在properties的配置文件中,将自定义的datasource的url之前加上jdbc即可

spring.datasource.secondary3.driverClassName=oracle.jdbc.OracleDriver
spring.datasource.secondary3.jdbc-url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.secondary3.username=glmedical
spring.datasource.secondary3.password=glmedical

二、springboot+mybatis多数据源步骤如下:

提示:完全可以在已有springboot+mybatis项目的基础上进行,根本不和别的类有丁点冲突,在已有整合的项目基础上只需3小步骤。

application.properties需要将自动识别的spring.datasource改为自定义(就是加个自定义的字段给他改喽),例子在?
application.properties多加个自定义数据源,例子在?
有几个数据源就加几个数据源配置类,数据源配置类配置?

  1. 构建springboot项目,项目构建不再提…
    文件目录:
    在这里插入图片描述

  2. dependence依赖引入

    <dependencies>
     <!--web相关依赖,-->
     <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
     </dependency>
     <!--mybatis和springboot整合依赖-->
     <dependency>
         <groupId>org.mybatis.spring.boot</groupId>
         <artifactId>mybatis-spring-boot-starte
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值