哎哟,不错哦

导航

boot 项目启动报Cannot datermine embedded database driver class for database type NONE

部署boot项目时报Cannot datermine embedded database driver class for database type NONE数据库链接什么的也都没有问题,经过百度

因为spring boot只要你在pom中引入了mybatis-spring-boot-starter 他就会默认需要加载数据库相关的配置

你要是没有在配置文件中配置数据相关信息,它会加载默认的配置(不存在的) 然后就报错了, 所以你要是要用数据库相关的东西 你就完善配置
不用数据库相关的东西 就不要在pom中引入相关依赖。

解决方法:1)应用没有使用到DataSource,但是在pom.xml里引入了spring-boot-starter-jdbc spring-boot-starter-jdbc带入了tomcat-jdbc,它里面有org.apache.tomcat.jdbc.pool.DataSource spring boot里的PooledDataSourceConfiguration,判断classpath下面有DataSource的实现类,尝试去创建DataSource bean 在初始化DataSourceProperties时,尝试通过jdbc的url来探测driver class 因为应用并没有配置url,所以最终在DataSourceProperties.determineDriverClassName()里抛出Cannot determine embedded database driver class for database type NONE,去除pom文件中没有用到的数据库jar

    2)在启动类注解上加上exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class }

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

 

posted on 2019-07-31 15:22  哎哟,不错哦  阅读(572)  评论(0编辑  收藏  举报