关于idea在springboot启动时报错Cannot determine embedded database driver class for database type NONE解决办法
第一种情况:我只是想使用idea读取 application.properties或者application.yml里配置的属性值时在不连接数据库启动springboot会出现:
Cannot determine embedded database driver class for database type NONE
原因是:springboot启动时会自动注入数据源和配置jpa
解决办法:在@SpringBootApplication中排除其注入
@SpringBootApplication(exclude{DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
第二种情况:此时我在application.properties或者application.yml文件中配置了数据库的连接信息,配置好之后启动Application,此时如果运气不好就会碰到和上面一样的错误,
Cannot determine embedded database driver class for database type NONE
此时我肯定是要连接数据库进行数据交互的,
那么Application启动类的注解上肯定是不需要加上
exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}
**那怎么办:**绝招了解一下,在你的pom依赖里加上这句就够了,重启有惊喜
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>