2018-01-16 15:56:14.104 [main] [] [] ERROR o.s.boot.springapplication-application startup failed org.springframework.be Ans.factory.BeanCreationException:Error creating bean with Name ' Org.springframework.boot.autoconfigure.jdbc.datasourceautoconfiguration$jdbctemplateconfiguration ': Injection of autowired dependencies failed; Nested exception is org.springframework.beans.factory.BeanCreationException:Could not Autowire field:private Javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.datasourceautoconfiguration$ Jdbctemplateconfiguration.datasource; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' DataSource ' Defined in class path resource [org/springframework/boot/autoconfigure/jdbc/datasourceautoconfiguration$ Nonembeddedconfiguration.class]: Bean instantiation via factory method failed; Nested exception is org.springframework.beans.BeanInstantiationException:Failed to instantiate [Javax.sql.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 a embedded database, put a supported one on the classpath. If you had database settings to is loaded from a particular profiles you may need to active it (the Profiles "dev" is cur
rently active). At Org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues ( autowiredannotationbeanpostprocessor.java:334) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( abstractautowirecapablebeanfactory.java:1214) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:543) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( Abstractautowirecapablebeanfactory.java:482) at Org.springframework.beans.factory.support.abstractbeanfactory$1.getobject ( abstractbeanfactory.java:306) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:230) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:302) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:197) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons ( defaultlistablebeanfactory.java:772) at Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization ( abstractapplicationcontext.java:839) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:538) at Org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh ( embeddedwebapplicationcontext.java:118) at Org.springframework.boOt. Springapplication.refresh (springapplication.java:766) at Org.springframework.boot.SpringApplication.createAndRefreshContext (springapplication.java:361) at Org.springframework.boot.SpringApplication.run (springapplication.java:307) at Org.springframework.boot.SpringApplication.run (springapplication.java:1191) at Org.springframework.boot.SpringApplication.run (springapplication.java:1180) at Com.mryx.mps.Application.main ( APPLICATION.JAVA:25) caused by:org.springframework.beans.factory.BeanCreationException:Could not autowire field: Private Javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.datasourceautoconfiguration$ Jdbctemplateconfiguration.datasource; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' DataSource ' Defined in class path resource [org/springframework/boot/autoconfigure/jdbc/datasourceautoconfiguration$ Nonembeddedconfiguration.class]: Bean instantiation via factory method failed; Nested ExceptiOn are org.springframework.beans.BeanInstantiationException:Failed to instantiate [Javax.sql.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 a embedded database, put a supported one on the classpath. If you had database settings to is loaded from a particular profiles you may need to active it (the Profiles "dev" is cur
rently active). At org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$ Autowiredfieldelement.inject (autowiredannotationbeanpostprocessor.java:573) at Org.springframework.beans.factory.annotation.InjectionMetadata.inject (injectionmetadata.java:88) at Org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues ( autowiredannotationbeanpostprocessor.java:331) ... Common Frames Omitted caused by:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' DataSource ' d Efined in class path resource [org/springframework/boot/autoconfigure/jdbc/datasourceautoconfiguration$ Nonembeddedconfiguration.class]: Bean instantiation via factory method failed; Nested exception is org.springframework.beans.BeanInstantiationException:Failed to instantiate [Javax.sql.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 a embedded database, put a supported one on the classpath. If you had database settings to is loaded from a particular profiles you may need to active it (the Profiles "dev" is cur
rently active). At Org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod (
constructorresolver.java:599) At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod ( abstractautowirecapablebeanfactory.java:1123) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance ( abstractautowirecapablebeanfactory.java:1018) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:510) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:482) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:306) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:230) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:302) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (Abstractbeanfactory.java:197) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates ( defaultlistablebeanfactory.java:1192) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency ( defaultlistablebeanfactory.java:1116) at Org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency ( DEFAULTLISTABLEBEANFACTORY.JAVA:1014) at Org.springframework.beans.factory.annotation.autowiredannotationbeanpostprocessor$autowiredfieldelement.inject (autowiredannotationbeanpostprocessor.java:545) ... Common frames omitted caused by:org.springframework.beans.BeanInstantiationException:Failed to instantiate [ Javax.sql.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 a embedded database please putA supported one on the classpath. If you had database settings to is loaded from a particular profiles you may need to active it (the Profiles "dev" is cur
rently active). At Org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate ( simpleinstantiationstrategy.java:189) at Org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod ( constructorresolver.java:588) ... Common frames omitted caused by:org.springframework.boot.autoconfigure.jdbc.datasourceproperties$ Datasourcebeancreationexception:cannot Determine embedded database driver class for database type NONE. If you want a embedded database, put a supported one on the classpath. If you had database settings to is loaded from a particular profiles you may need to active it (the Profiles "dev" is cur
rently active). At Org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName ( datasourceproperties.java:180) at Org.springframework.boot.autOconfigure.jdbc.datasourceautoconfiguration$nonembeddedconfiguration.datasource ( datasourceautoconfiguration.java:121) at Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) at Sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source) at Sun.reflect.DelegatingMethodAccessorImpl.invoke ( Unknown source) at Java.lang.reflect.Method.invoke (Unknown source) at Org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate ( simpleinstantiationstrategy.java:162) ... Common frames omitted
Reason:
This is because spring boot will load the Org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration class by default,
The Datasourceautoconfiguration class uses the @configuration annotation to inject datasource beans into spring. Because there is no configuration information related to datasource in the project, the spring creation DataSource Bean will be error-free due to lack of relevant information. Solutions
@EnableAutoConfiguration (Exclude={datasourceautoconfiguration.class})