在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

最新文章

  1. C# 自动生成代码API文档
  2. 深入浅出设计模式——备忘录模式(Memento Pattern)
  3. 转:Directshow开发的一些例子
  4. DirectShow程序运行过程简析
  5. zlib导致Ubuntu登录管理器失效
  6. jetty属性
  7. ThinkPadTablet如何恢复出厂状态
  8. MAC 下安装PIL
  9. [Qt] Mask 蒙版
  10. java面试题集1
  11. 西安力邦智能医疗&可穿戴设备沙龙--第1期---苹果HealthKit、谷歌GoogleFit来袭,智能医疗要爆发吗?
  12. ANDROID L——Material Design详细解释(UI控制)
  13. 自学Zabbix3.7-事件Event
  14. 第5章 PCIe总线的事务层
  15. Factorized TDNN(因子分解TDNN,TDNN-F)
  16. java常用工具包
  17. WPF 绕圈进度条(二)
  18. Codeforces 1136C - Nastya Is Transposing Matrices
  19. python:id与小数据池与编码
  20. Vue父组件接收不到子组件$emit事件的原因分析

热门文章

  1. 0x15 字符串
  2. hadoop学习(四)----windows环境下安装hadoop
  3. Chrome 开发工具之 Memory
  4. javacv——读取摄像头的图像、截取视频的画面
  5. 如何让textarea placeholder 文字垂直居中
  6. mybatis批量更新策略
  7. I firmly believe
  8. 网络安全攻击与防护--HTML学习
  9. 【JS档案揭秘】第四集 关于this的讨论到此为止
  10. springmvc集成swaggerui