Spring boot出现Cannot determine embedded database driver class for database type NONE
2024-10-20 18:59:18
在spring boot项目中,我们在pom.xml文件中添加了mysql和mybatis的依赖,我们常常遇到下面这样的问题:
Description: Cannot determine embedded database driver class for database type NONE Action: If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
出现这个问题,是因为spring boot在项目启动的时候会注入数据源,而我们在配置文件中又没有配置数据库,因此会报这样的错误。
解决办法:
1.当然是直接注释掉pom.xml文件中的mysql和mybatis的依赖,这样spring boot启动的时候当然不会注入数据源了,因此也就不会报错了。
2.在@SpringBootApplication中排除其注入
@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
3.直接在配置文件配置一下数据库连接就好了嘛,多简单的事,那当然就不会报错了。
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=root
最新文章
- C# 自动生成代码API文档
- 深入浅出设计模式——备忘录模式(Memento Pattern)
- 转:Directshow开发的一些例子
- DirectShow程序运行过程简析
- zlib导致Ubuntu登录管理器失效
- jetty属性
- ThinkPadTablet如何恢复出厂状态
- MAC 下安装PIL
- [Qt] Mask 蒙版
- java面试题集1
- 西安力邦智能医疗&;amp;可穿戴设备沙龙--第1期---苹果HealthKit、谷歌GoogleFit来袭,智能医疗要爆发吗?
- ANDROID L——Material Design详细解释(UI控制)
- 自学Zabbix3.7-事件Event
- 第5章 PCIe总线的事务层
- Factorized TDNN(因子分解TDNN,TDNN-F)
- java常用工具包
- WPF 绕圈进度条(二)
- Codeforces 1136C - Nastya Is Transposing Matrices
- python:id与小数据池与编码
- Vue父组件接收不到子组件$emit事件的原因分析