Spring Boot –无法确定数据库类型NONE的嵌入式数据库驱动程序类

本文介绍了在运行Spring Boot应用时遇到'无法确定数据库类型NONE的嵌入式数据库驱动程序类'错误的原因及解决方案。该错误通常由于未配置数据源引起。修复方法包括在Spring Boot应用类中排除DataSource的自动配置,或者在application.properties文件中提供数据源配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

If you are reading this, then I think you have got “Cannot determine embedded database driver class for database type NONE” error while running Spring Boot application. Below image shows my simple Spring Boot starter project where I got “Cannot determine embedded database driver class for database type NONE” error while running the JUnit test case.

如果您正在阅读本文,那么我认为运行Spring Boot应用程序时会出现“无法确定数据库类型NONE的嵌入式数据库驱动程序类”错误。 下图显示了我的简单Spring Boot入门项目,在运行JUnit测试用例时,出现“ 无法确定数据库类型NONE的嵌入式数据库驱动程序类 ”错误。

无法确定数据库类型NONE的嵌入式数据库驱动程序类 (Cannot determine embedded database driver class for database type NONE)

This error comes when you don’t have a DataSource configured for your spring boot application. When you run spring boot application, it tries to configure the DataSource and throws this error message when there is no configuration provided.

当您没有为Spring Boot应用程序配置数据源时,就会出现此错误。 当您运行spring boot应用程序时,它会尝试配置DataSource并在没有提供配置时抛出此错误消息。

Below are the classes that I had in my spring boot starter project.

以下是我在Spring Boot Starter项目中拥有的类。

package com.journaldev.spring;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBatchHelloWorldApplication {

	public static void main(String[] args) {
		SpringApplication.run(SpringBatchHelloWorldApplication.class, args);
	}
}
package com.journaldev.spring;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class SpringBatchHelloWorldApplicationTests {

	@Test
	public void contextLoads() {
	}

}

My application.properties file was empty. Now when I execute about JUnit class, it give below error.

我的application.properties文件为空。 现在,当我执行有关JUnit类的操作时,它给出以下错误。

11:42:49.460 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
11:42:49.469 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
11:42:49.474 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
11:42:49.486 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
11:42:49.495 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests], using SpringBootContextLoader
11:42:49.498 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]: class path resource [com/journaldev/spring/SpringBatchHelloWorldApplicationTests-context.xml] does not exist
11:42:49.498 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]: class path resource [com/journaldev/spring/SpringBatchHelloWorldApplicationTestsContext.groovy] does not exist
11:42:49.499 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
11:42:49.499 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]: SpringBatchHelloWorldApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
11:42:49.532 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
11:42:49.539 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
11:42:49.540 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
11:42:49.540 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
11:42:49.547 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved classpath location [com/journaldev/spring/] to resources [URL [file:/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/test-classes/com/journaldev/spring/], URL [file:/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/classes/com/journaldev/spring/]]
11:42:49.548 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/test-classes/com/journaldev/spring]
11:42:49.548 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/test-classes/com/journaldev/spring] for files matching pattern [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/test-classes/com/journaldev/spring/*.class]
11:42:49.551 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/classes/com/jo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值