在网上看了很多种办法,大部分都需要手动下载jar包并引入到maven仓库中才能在springboot项目中使用,其实也有不需要手动引入的方法,直接添加依赖到pom文件中并设置连接属性更为方便和快捷,这里介绍下github上的一个连接oracle驱动包,首先在pom.xml文件中引入依赖。

<dependency>
			<groupId>com.github.noraui</groupId>
			<artifactId>ojdbc7</artifactId>
			<version>12.1.0.2</version>
		</dependency>

在application.yml 中设置连接属性(yml或者properties设置的方法大同小异)

spring:
   datasource:
      driver-class-name: oracle.jdbc.driver.OracleDriver
      url: jdbc:oracle:thin:@主机号:端口号:数据库名称
      username: 用户名
      password: 密码

mybatis:
  mapper-locations: classpath:mapping/*.xml

接着项目就可以连接并且利用mybatis操作oracle数据库了,测试方法就不写了。

 

更多推荐

SpringBoot连接oracle数据库(最简单的方法)