SpringBoot:Cannot determine embedded database driver class for database type NONE

本人在启动SpringCloud微服务时,报监听不到数据源。由于底层是c++操作数据库,用jni将c++的接口转成java实现,然后微服务发布。在使用时项目里就没有配置数据源,但是还需要将spring-boot-starter-jdbc的依赖去掉或者把spring boot自动初始化DataSource相关的代码禁止掉。

SpringBoot:Cannot determine embedded database driver class for database type NONE

问题解决办法

有两种:

    1、没有使用到DataSource,则可以把spring-boot-starter-jdbc的依赖去掉,这样就不会触发spring boot相关的代码
    2、把spring boot自动初始化DataSource相关的代码禁止掉

禁止的办法有两种:

    1、在main函数上配置exclude 

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

SpringBoot:Cannot determine embedded database driver class for database type NONE

   2、在application.properties里配置:

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration 

参考:https://blog.csdn.net/hengyunabc/article/details/78762097