当前位置:网站首页>笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决
笔记——记录一个CannotFindDataSourceException: dynamic-datasource can not find primary datasource问题解决
2022-07-25 19:49:00 【专注写bug】
文章目录
问题场景
将Springboot项目升级为Springcloud项目,由于配置多数据源,出了一堆稀奇古怪的坑。
其中,有个CannotFindDataSourceException: dynamic-datasource can not find primary datasource坑,琢磨了半天,居然神奇般的解决。
解决方式很奇怪,请继续向下看。
环境配置
- nacos 1.3.0
- dynamic-datasource 3.5.0
问题列表和解决方式
dynamic-datasource please check the setting of primary
出现dynamic-datasource please check the setting of primary这类问题,如果配置文件都正确的情况下,依旧出现下列所描述的报错:
说明当前dynamic-datasource的依赖版本和Springboot版本不兼容问题
需要升级
dynamic-datasource的pom版本。
参考博客
dynamic-datasource can not find primary datasource
如果配置类信息都正确无误,同时针对spring.datasource.dynamic.datasource中数据源,增加了默认的master节点,或者配置其他节点名称。
如果是配置其他名称,则需要增加spring.datasource.dynamic.datasource.primary指向。
这里注意一点,如果设置有
spring.datasource.dynamic.datasource.xxxx.poolName。
那么spring.datasource.dynamic.datasource.primary会查找对应poolName相匹配的节点配置信息。
如果nacos中,配置文件要求等都正常,依旧无法获取到配置中心中的配置信息,或在配置文件变更后,程序日志打印中无自动拉取配置和重启的log打印,此时最直接的做法:
重启nacos!
参考博客
边栏推荐
- Software designer afternoon real topic: 2009-2022
- 由一个蓝桥杯基础题报时助手而引出的常见误区
- 如何保证定制滑环质量
- 浅谈接口加密
- Siemens-PLM-TeamCenter下载、安装、使用教程
- NPM semantic version control, solution console prop being mutated: "placement" error
- [good book recommendation] - authoritative guide to Ethernet (2nd Edition)
- How to get started quickly in software testing
- [mindspore] [read graph data] cannot read mindrecord format graph data
- TypeError: ‘str‘ object is not callable的错误原因
猜你喜欢

03-树1 树的同构

How to get started quickly in software testing

wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M

Wechat applet 10 - wechat template

授权无线通信标准

YOLOv7论文部分解读【含自己的理解】

Why learn service grid istio

Sentinel simple current limiting and degradation demo problem record

AAAI 2022 | GAN的结构有“指纹”吗?从伪造图像溯源生成网络结构

A high efficiency 0-delay 0-copy QT player scheme based on Hisilicon 3559
随机推荐
[artifact] screenshot + mapping tool snipaste
高端旗舰投影仪选购指南:当贝X3 Pro、当贝F5观影更沉浸!
什么是唯心主义
Scala基础【集合01】
High number_ Chapter 3 learning experience and summary of multiple integral
GBASE 8s UDR内存管理_03_mi_realloc
Wechat applet 10 - wechat template
GBASE 8s UDR内存管理_01_mi_alloc
[wp]ctfshow-web getting started - Explosion
[CSAPP Practice Problem 2.32] tsub_ OK (int x, int y) judge whether complement subtraction overflows
balanced binary tree
C merge set
Flutter tips: optimizing the buildcontext you use
Hash undirected graph visualization
Wxss template style and WXS scripting language for wechat applet development
Nezha d1-h test microbench
VMware virtual machine download, installation and use tutorial
Why learn service grid istio
tiktok如何破零播放?
Scala foundation [set 01]