关于idea在springboot启动时报错Cannot determine embedded database driver class for database type NONE解决办法

场景一:  我只是想使用idea读取 application.properties或者application.yml里配置的属性值时然后在控制台输出瞧瞧,因为听说自动读取会很拽的样子,不过不连接数据库启动springboot会出现:
  1. Cannot determine embedded database driver class for database type NONE  

原因是:springboot启动时会自动注入数据源和配置jpa

解决办法:在@SpringBootApplication中排除其注入

@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})

正确截图如下:

在自己的Application启动类的注解上加上exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}



场景二:此时我在application.properties或者application.yml文件中配置了数据库的连接信息
1.假设配置连接数据如下


2.配置好之后启动Application,此时如果运气不好就会碰到和上面一样的错误,

  1. Cannot determine embedded database driver class for database type NONE  

可是我明明是配置了propertice配置文件的,然后还提示我这样做

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).

3.此时我肯定是要连接数据库进行数据交互的,

那么Application启动类的注解上肯定是不需要加上exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}


4.何解??  这不绕到一个死循环里面了吗?

客官,莫急,速效救心丸了解一下,在你的pom依赖里加上这句就够了,重启有惊喜

<dependency>
        <groupId>com.h2database</groupId> 
        <artifactId>h2</artifactId>
        <scope>runtime</scope> 
</dependency>

  • 45
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 52
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 52
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值