当前位置:Gxlcms > 数据库问题 > 解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)

解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)

时间:2021-07-01 10:21:17 帮助过:12人阅读

Tomcat.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[org.apache.tomcat.jdbc.pool.DataSource]:FactorymethoddataSourcethrewexception;nestedexceptionisorg.springframework.boot.autoconfigure.jdbc.DataSourcePropertiesDataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. 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).

2017-07-16 08:50:58.240  INFO 13524 --- [           main] utoConfigurationReportLoggingInitializer : 

 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug‘ enabled.

2017-07-16 08:50:58.240 ERROR 13524 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

 

 

***************************

APPLICATION FAILED TO START

***************************

 

Description:

 

Cannot determine embedded database driver class for database type NONE

 

Action:

 

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

 

 

Process finished with exit code 1

 

------------------------我是分割线------------------

网上 找到了所谓的解决 方法:

?
1234567891011@SpringBootApplication(exclude = {         DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class},scanBasePackages = {"com.ppdai.pointshop.web.controller"})public class PointshopWebApplication {     public static void main(String[] args) {        SpringApplication.run(PointshopWebApplication.class, args);    }}

  但是很 遗憾 ,没用。

于是 用maven下载 好springboot 的源码,然后断点调试 进去 ,看看 是什么情况,最后 发现了问题的所在:

技术分享图片

因为我这是一个新 项目 ,还 没有 配置数据源 ,但是我又想在 没配置数据源的情况 下去 启动项目,该怎么办呢 ?网上找到的方法是无效的,于是我做了一个大胆的猜测:肯定是某个地方加载了这个bean,因为 这是 一个新项目,所以 我觉得 启动加载的可能性很大,而启动 加载 只有 POM文件 里面的依赖才 有可能办到。下面 是 我的dependency依赖:

?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364<dependencies>    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-autoconfigure -->    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-autoconfigure</artifactId>        <version>1.5.4.RELEASE</version>    </dependency>    <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot -->    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot</artifactId>        <version>1.5.4.RELEASE</version>    </dependency>      <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-aop</artifactId>        <version>1.5.4.RELEASE</version>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-data-redis</artifactId>        <version>1.5.4.RELEASE</version>    </dependency>    <dependency>        <groupId>org.mybatis.spring.boot</groupId>        <artifactId>mybatis-spring-boot-starter</artifactId>        <version>1.3.0</version>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-web</artifactId>        <version>1.5.4.RELEASE</version>    </dependency>     <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-tomcat</artifactId>        <version>1.5.4.RELEASE</version>        <scope>provided</scope>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-test</artifactId>        <version>1.5.4.RELEASE</version>        <scope>test</scope>    </dependency>     <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->    <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-core</artifactId>        <version>4.3.9.RELEASE</version>    </dependency>    <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->    <dependency>        <groupId>org.springframework</groupId>        <artifactId>spring-context</artifactId>        <version>4.3.9.RELEASE</version>    </dependency>  </dependencies>

  一个个排查,最后查到org.mybatis.spring.boot这个依赖 ,注释掉即可,可以发现,调试的时候 beannames明显少了很多。

?
12345<dependency>   <groupId>org.mybatis.spring.boot</groupId>   <artifactId>mybatis-spring-boot-starter</artifactId>   <version>1.3.0</version></dependency>

技术分享图片

最终,Spring Boot 启动成功!

技术分享图片

 

 

解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE(转)

标签:void   ota   sep   gap   href   cat   poi   inter   toolbar   

人气教程排行