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

 springboot启动报错如下图:

出错原因:springboot启动时会自动注入数据源及配置jpa

解决办法:

1,在pom文件中加h2引用

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

 2.在启动类上加上

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

 3,以上解决办法只是针对该springboot应用不与数据库之间有交互的场景下,使用,

若应用与数据库有交互,那么@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}) 是不能用的!!!!!

猜你喜欢

转载自www.cnblogs.com/liqiang0728/p/11777405.html