spring.boot 无法加载oracle驱动的可能原因

时间:2021-11-16 09:35:35
.找到本地oracle安装目录下的ojdbc6.jar包,为了方便起见,复制到某盘的根目录(如F盘根目录),在cmd下进入F盘根目录(也就是ojdbc.jar复制的目录),同时我们需要查看ojdbc的版本号,打开ojdbc.jar,找到META-INF/打开MANIFEST.MF
我们可以清晰的看到版本号: Implementation-Version: 11.2.
.cd /d f:
3 命令行设置
3.1 我的客户端安装在C:\app\admin\product\11.2.0\client_1,为了方便我把ojdbc6.jar放到F盘根目录
3.2 mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2. -Dpackaging=jar -Dfile=ojdbc6.jar
. 第三步如果最终显示build success,再看这一步,这里提供两种配置配置application的配置文件application.properties或者application.properties.yml。4.1或4.2选择一种即可
4.1 application.properties
spring.datasource.url=jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.11)(PORT = )) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hra_dev)))
spring.datasource.username=RAMS_XY_TO_GARY
spring.datasource.password=RAMS_XY_TO_GARY
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.max-idle=
spring.datasource.max-wait=
spring.datasource.min-idle=
spring.datasource.initial-size=
#XMLÎļþλÖÃ
# mybatis.mapperLocations=classpath:mapper/*.xml
mybatis.mapper-locations=classpath*:mapper/*Mapper.xml
mybatis.type-aliases-package=com.cwh.springbootMybatis.entity
4.2 application.yml 注意下面冒号后都有空格这点很重要 如 port: 8888 实际读作port:空格8888
server:
prot: 8888  #配置访问的端口 spring:
datasource:
url: jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.252)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hra_dev)))
username: RAMS_XY_TO_GARY  #数据库登录名
password: RAMS_XY_TO_GARY #登陆密码
driver-class-name: oracle.jdbc.driver.OracleDriver
filters: stat
maxActive: 20  #连接池的最大值,同一时间可以从池分配的最多连接数量,0时无限制
initialSize: 1  #连接初始值,连接池启动时创建的连接数量的初始值
maxWait: 60000
minIdle: 1  #最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: select 'x'
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
poolPreparedStatements: true   #是否对已备语句进行池管理(布尔值),是否对PreparedStatement进行缓存
maxOpenPreparedStatements: 20 jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8 mybatis-plus:
mapper-locations: classpath*:mapper/**/*Mapper.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.yudao.platform.entity.*
global-config:
#主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
id-type: 0
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
field-strategy: 2
#驼峰下划线转换
db-column-underline: false
#刷新mapper 调试神器
refresh-mapper: true
#数据库大写下划线转换
#capital-mode: true
# Sequence序列接口实现类配置
#key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
#逻辑删除配置
logic-delete-value: 1
logic-not-delete-value: 0
#自定义填充策略接口实现
#meta-object-handler: com.baomidou.springboot.xxx
#自定义SQL注入器
# sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
 5. 最后有时候配置你可能是从网页复制过来,那么编码可能有问题,你需要确认下 6. 恭喜看到这里你应该成功了
7.参考 https://www.cnblogs.com/lqtbk/p/9843401.html
8.配置文件下载: 链接:https://pan.baidu.com/s/1XEt1yzwVsSEUBp_b2NoOTw
提取码:hu88