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

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. Cannot determine embedded database driver class for database type NONE

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

此错误发生时,您没有为您的春天启动应用程序配置数据源。当您运行春天启动应用程序时,它试图配置数据源并在没有配置提供时丢弃此错误消息。

 1package com.journaldev.spring;
 2
 3import org.springframework.boot.SpringApplication;
 4import org.springframework.boot.autoconfigure.SpringBootApplication;
 5
 6@SpringBootApplication
 7public class SpringBatchHelloWorldApplication {
 8
 9    public static void main(String[] args) {
10    	SpringApplication.run(SpringBatchHelloWorldApplication.class, args);
11    }
12}
 1package com.journaldev.spring;
 2
 3import org.junit.Test;
 4import org.junit.runner.RunWith;
 5import org.springframework.boot.test.context.SpringBootTest;
 6import org.springframework.test.context.junit4.SpringRunner;
 7
 8@RunWith(SpringRunner.class)
 9@SpringBootTest
10public class SpringBatchHelloWorldApplicationTests {
11
12    @Test
13    public void contextLoads() {
14    }
15
16}

我的 application.properties 文件是空的. 現在當我執行關於 JUnit 類別時,它會給下面的錯誤。

  111:42:49.460 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
  211:42:49.469 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
  311: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)]
  411: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]
  511: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
  611: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
  711: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
  811: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}.
  911: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.
 1011: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]
 1111:42:49.539 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
 1211:42:49.540 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
 1311:42:49.540 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
 1411: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/]]
 1511: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]
 1611: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]
 1711: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/journaldev/spring]
 1811:42:49.551 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Searching directory [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/classes/com/journaldev/spring] for files matching pattern [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/classes/com/journaldev/spring/*.class]
 1911:42:49.551 [main] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:com/journaldev/spring/*.class] to resources [file [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/test-classes/com/journaldev/spring/SpringBatchHelloWorldApplicationTests.class], file [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/classes/com/journaldev/spring/SpringBatchHelloWorldApplication.class]]
 2011:42:49.589 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [/Users/pankaj/CODE/hackathon/SpringBatchHelloWorld/target/classes/com/journaldev/spring/SpringBatchHelloWorldApplication.class]
 2111:42:49.590 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.journaldev.spring.SpringBatchHelloWorldApplication for test class com.journaldev.spring.SpringBatchHelloWorldApplicationTests
 2211:42:49.592 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]: using defaults.
 2311:42:49.597 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
 2411:42:49.612 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Could not instantiate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener]. Specify custom listener classes or make the default listener classes (and their required dependencies) available. Offending class: [javax/servlet/ServletContext]
 2511:42:49.612 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@587d1d39, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@58c1670b, org.springframework.test.context.support.DirtiesContextTestExecutionListener@6b57696f, org.springframework.test.context.transaction.TransactionalTestExecutionListener@5bb21b69, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@6b9651f3, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@38bc8ab5, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@687080dc, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@23d2a7e8, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@7a9273a8, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@26a7b76d, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@4abdb505]
 2611:42:49.613 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 2711:42:49.614 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 2811:42:49.623 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 2911:42:49.623 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 3011:42:49.624 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 3111:42:49.624 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 3211:42:49.624 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 3311:42:49.624 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 3411:42:49.627 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@69b0fd6f testClass = SpringBatchHelloWorldApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@757942a1 testClass = SpringBatchHelloWorldApplicationTests, locations = '{}', classes = '{class com.journaldev.spring.SpringBatchHelloWorldApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.SpringBootTestContextCustomizer@6ea12c19, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@174d20a, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@4f933fd1], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]]], class annotated with @DirtiesContext [false] with mode [null].
 3511:42:49.627 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 3611:42:49.627 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.journaldev.spring.SpringBatchHelloWorldApplicationTests]
 3711:42:49.628 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@69b0fd6f testClass = SpringBatchHelloWorldApplicationTests, testInstance = com.journaldev.spring.SpringBatchHelloWorldApplicationTests@b7dd107, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@757942a1 testClass = SpringBatchHelloWorldApplicationTests, locations = '{}', classes = '{class com.journaldev.spring.SpringBatchHelloWorldApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.SpringBootTestContextCustomizer@6ea12c19, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@174d20a, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@4f933fd1], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]]]].
 3811:42:49.676 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemProperties] PropertySource with lowest search precedence
 3911:42:49.676 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [systemEnvironment] PropertySource with lowest search precedence
 4011:42:49.676 [main] DEBUG org.springframework.core.env.StandardEnvironment - Initialized StandardEnvironment with PropertySources [systemProperties,systemEnvironment]
 4111:42:49.677 [main] DEBUG org.springframework.core.env.MutablePropertySources - Adding [inline] PropertySource with highest search precedence
 4211:42:49.681 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}
 4311:42:49.681 [main] DEBUG org.springframework.core.env.StandardEnvironment - Adding [Inlined Test Properties] PropertySource with highest search precedence
 44
 45  . ____ _ __ _ _
 46 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
 47( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 48 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
 49  '  |____| .__|_| |_|_| |_\__, | / / / /
 50 =========|_|==============|___/=/_/_/_/
 51 :: Spring Boot ::        (v1.5.1.RELEASE)
 52
 532017-03-04 11:42:49.876 INFO 51131 --- [           main] .s.SpringBatchHelloWorldApplicationTests : Starting SpringBatchHelloWorldApplicationTests on pankaj.local with PID 51131 (started by pankaj in /Users/pankaj/CODE/hackathon/SpringBatchHelloWorld)
 542017-03-04 11:42:49.877 INFO 51131 --- [           main] .s.SpringBatchHelloWorldApplicationTests : No active profile set, falling back to default profiles: default
 552017-03-04 11:42:49.902 INFO 51131 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@59474f18: startup date [Sat Mar 04 11:42:49 IST 2017]; root of context hierarchy
 562017-03-04 11:42:50.311 WARN 51131 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; 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).
 572017-03-04 11:42:50.318 INFO 51131 --- [           main] utoConfigurationReportLoggingInitializer : 
 58
 59Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
 602017-03-04 11:42:50.322 ERROR 51131 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
 61
 62***************************
 63APPLICATION FAILED TO START
 64***************************
 65
 66Description:
 67
 68Cannot determine embedded database driver class for database type NONE
 69
 70Action:
 71
 72If 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).
 73
 74  . ____ _ __ _ _
 75 /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
 76( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 77 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
 78  '  |____| .__|_| |_|_| |_\__, | / / / /
 79 =========|_|==============|___/=/_/_/_/
 80 :: Spring Boot ::        (v1.5.1.RELEASE)
 81
 822017-03-04 11:42:50.347 INFO 51131 --- [           main] .s.SpringBatchHelloWorldApplicationTests : Starting SpringBatchHelloWorldApplicationTests on pankaj.local with PID 51131 (started by pankaj in /Users/pankaj/CODE/hackathon/SpringBatchHelloWorld)
 832017-03-04 11:42:50.348 INFO 51131 --- [           main] .s.SpringBatchHelloWorldApplicationTests : No active profile set, falling back to default profiles: default
 842017-03-04 11:42:50.349 INFO 51131 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@2a448449: startup date [Sat Mar 04 11:42:50 IST 2017]; root of context hierarchy
 852017-03-04 11:42:50.475 WARN 51131 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; 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).
 862017-03-04 11:42:50.477 INFO 51131 --- [           main] utoConfigurationReportLoggingInitializer : 
 87
 88Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
 892017-03-04 11:42:50.479 ERROR 51131 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
 90
 91***************************
 92APPLICATION FAILED TO START
 93***************************
 94
 95Description:
 96
 97Cannot determine embedded database driver class for database type NONE
 98
 99Action:
100
101If 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).
102
1032017-03-04 11:42:50.486 ERROR 51131 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@58c1670b] to prepare test instance [com.journaldev.spring.SpringBatchHelloWorldApplicationTests@b7dd107]
104
105java.lang.IllegalStateException: Failed to load ApplicationContext
106    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
107    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:83) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
108    at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:47) ~[spring-boot-test-autoconfigure-1.5.1.RELEASE.jar:1.5.1.RELEASE]
109    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:230) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
110    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:228) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
111    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:287) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
112    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.12.jar:4.12]
113    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:289) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
114    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:247) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
115    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
116    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) [junit-4.12.jar:4.12]
117    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) [junit-4.12.jar:4.12]
118    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) [junit-4.12.jar:4.12]
119    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) [junit-4.12.jar:4.12]
120    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) [junit-4.12.jar:4.12]
121    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
122    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
123    at org.junit.runners.ParentRunner.run(ParentRunner.java:363) [junit-4.12.jar:4.12]
124    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) [spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
125    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) [.cp/:na]
126    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
127    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) [.cp/:na]
128    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) [.cp/:na]
129    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) [.cp/:na]
130    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) [.cp/:na]
131Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; 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).
132    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
133    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
134    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
135    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
136    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
137    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
138    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
139    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
140    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
141    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
142    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
143    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
144    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
145    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
146    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
147    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) ~[spring-boot-test-1.5.1.RELEASE.jar:1.5.1.RELEASE]
148    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:98) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
149    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:116) ~[spring-test-4.3.6.RELEASE.jar:4.3.6.RELEASE]
150    ... 24 common frames omitted
151Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; 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).
152    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
153    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
154    ... 41 common frames omitted
155Caused by: 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).
156    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:246) ~[spring-boot-autoconfigure-1.5.1.RELEASE.jar:1.5.1.RELEASE]
157    at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:183) ~[spring-boot-autoconfigure-1.5.1.RELEASE.jar:1.5.1.RELEASE]
158    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:42) ~[spring-boot-autoconfigure-1.5.1.RELEASE.jar:1.5.1.RELEASE]
159    at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat.dataSource(DataSourceConfiguration.java:56) ~[spring-boot-autoconfigure-1.5.1.RELEASE.jar:1.5.1.RELEASE]
160    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_73]
161    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_73]
162    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_73]
163    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_73]
164    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
165    ... 42 common frames omitted

Fix for 无法确定数据库类型的嵌入式数据库驱动程序类别 NONE

正如你可以看到的,我的Java类没有任何东西,所以错误必须与Spring Boot有关。

  1. 联合国 不包括"春靴"应用类中数据源的自动配置. 我们可以使用以下代码所显示的 EnableAutofignation 注释。 QQ 软件包 com.journaldev.spring;

导入 org.springframework.boot.SpringApplication; () ) 导入 org.springframework.boot.autoconfult. EnableAutofiguation; 导入 org.springform.boot.autApplication; 导入 org.springframework.boot.autoconfult.jdbc.Data sourceAutofult; @SpringBootApplication @ EnableAutoformation(不包括e-Data source-autAutofulculation.class) () ) 公共类 SpringBatch Hello World 应用程序 { _ 公有静态空置主干(String[] args){ SpringApplication.run(SpringBatch Hello WorldApplication.class, args)}}} } }> 上方配置,JUnit 测试例执行得很好,不再不能确定数据库类型NE错误的嵌入式数据库驱动程序类。 2. 解决这一问题的另一种方法是在应用程序'中提供spring.datasource.url'。 属性文件。 虽然我并没有提供任何数据库用户名和密码,但它对我有效. (_ _) QQ spring.datasource.url=jdbc:mysql://localhost/Test_DB QQ

这是为了修复春天启动数据源错误,我希望这些修复可以帮助您解决春天启动应用程序的问题。

Published At
Categories with 技术
Tagged with
comments powered by Disqus