关于idea在springboot启动时报错Cannot determine embedded database driver class for database type NONE解决办法

本文详细解析了在使用SpringBoot框架时如何正确配置application.properties或application.yml文件来避免Cannot determine embedded database driver class for database type NONE错误的发生,并介绍了如何在不启动数据库的情况下查看配置属性值的方法。

场景一:  我只是想使用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}



场景二:此时我在application.properties或者application.yml文件中配置了数据库的连接信息
1.假设配置连接数据如下


2.配置好之后启动Application,此时如果运气不好就会碰到和上面一样的错误,

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

3.此时我肯定是要连接数据库进行数据交互的,

那么Application启动类的注解上肯定是不需要加上exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}


4.何解??  这不绕到一个死循环里面了吗?

客官,莫急,速效救心丸了解一下,在你的pom依赖里加上这句就够了,重启有惊喜

<dependency>
        <groupId>com.h2database</groupId> 
        <artifactId>h2</artifactId>
        <scope>runtime</scope> 
</dependency>

%xwEx2025-10-29 10:27:53.677 INFO 3037618 --- [ main] o.s.b.w.s.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] %xwEx2025-10-29 10:27:53.677 INFO 3037618 --- [ main] o.s.b.w.s.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*] %xwEx2025-10-29 10:27:53.677 INFO 3037618 --- [ main] o.s.b.w.s.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*] %xwEx2025-10-29 10:27:53.786 INFO 3037618 --- [ main] c.h.q.p.c.e.b.h.ErrorCodeContainer : %xwEx2025-10-29 10:27:54.260 WARN 3037618 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'reportFileApiServiceImpl': Unsatisfied dependency expressed through field 'exportAutoTask'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'exportAutoTask': Unsatisfied dependency expressed through field 'fundInfoAtom'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fundInfoAtomImpl': Unsatisfied dependency expressed through field 'fundInfoMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fundInfoMapper' defined in file [/media/GTZQ/DATA/workspace/hundsun-ext/amop-tgreportfacade/amop-tgreportfacade-service/target/classes/com/hundsun/amop/tgreportfacade/server/datasource/dao/FundInfoMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/hundsun/amop/tgreportfacade/server/config/MultipleDataSourceConfig.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dynamicDataSource' defined in class path resource [com/hundsun/amop/tgreportfacade/server/config/MultipleDataSourceConfig.class]: Unsatisfied dependency expressed through method 'dynamicDataSource' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tgdatasource' defined in class path resource [com/hundsun/amop/tgreportfacade/server/config/MultipleDataSourceConfig.class]: Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: 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). %xwEx2025-10-29 10:27:54.267 INFO 3037618 --- [ main] c.a.d.r.s.AbstractRegistryFactory : [DUBBO] Close all registries [], dubbo version: 2.0.32.2, current host: 127.0.0.1 %xwEx2025-10-29 10:27:54.323 INFO 3037618 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. %xwEx2025-10-29 10:27:54.334 ERROR 3037618 --- [ 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). %xwEx2025-10-29 10:27:54.347 INFO 3037618 --- [bboShutdownHook] c.a.d.c.AbstractConfig : [DUBBO] Notify IAR that current server is shutting down, dubbo version: 2.0.32.2, current host: 127.0.0.1 %xwEx2025-10-29 10:27:54.352 INFO 3037618 --- [bboShutdownHook] c.a.d.c.AbstractConfig : [DUBBO] Run shutdown hook now., dubbo version: 2.0.32.2, current host: 127.0.0.1 %xwEx2025-10-29 10:27:54.352 INFO 3037618 --- [bboShutdownHook] c.a.d.r.s.AbstractRegistryFactory : [DUBBO] Close all registries [], dubbo version: 2.0.32.2, current host: 127.0.0.1 %xwExDisconnected from the target VM, address: '127.0.0.1:36477', transport: 'socket'
最新发布
10-30
评论 52
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值