原文:https://blog.csdn.net/Master_Shifu_/article/details/80420099
场景一: 我只是想使用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}
————————————————
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019102817485
场景二:此时我在application.properties或者application.yml文件中配置了数据库的连接信息
1.假设配置连接数据如下
2.配置好之后启动Application,此时如果运气不好就会碰到和上面一样的错误,
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).
————————————————
加入下面的maven依赖即可
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
————————————————