spriing Boot Boot error: Cannot determine embedded database driver class for database type NONE

Source: Internet
Author: User
Tags acer

Recently learning to use Spring boot. Use MAVEN to create a project that references only the spring boot-related jar packages that need to be used, except that there are no configurations.

Write a simple example as follows:

1  PackageCom.torlight;2 3 Importorg.springframework.boot.SpringApplication;4 Importorg.springframework.boot.autoconfigure.EnableAutoConfiguration;5 Importorg.springframework.boot.autoconfigure.SpringBootApplication;6 Importorg.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;7 ImportOrg.springframework.context.ApplicationContext;8 ImportOrg.springframework.context.ConfigurableApplicationContext;9 Ten  One /** A  * @since2017.05.06 -  * @authorAcer -  * the  */ - @SpringBootApplication -  Public classApplication { -      +      Public Static voidMain (string[] args) { -ApplicationContext appctx= springapplication.run (application.class, args); +          ASystem.out.println ("appctx.getbeandefinitioncount=" +Appctx.getbeandefinitioncount ()); at         Try { - ((Configurableapplicationcontext) appctx). Close (); -}Catch(Exception e) {/*Ignore*/ } -     } -}

After running the program, the console outputs an error log:

017-05-06 22:44:18.868 WARN 41648---[Restartedmain] ationconfigembeddedwebapplicationcontext:exception encountered D Uring 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/D Atasourceconfiguration$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 a embedded database, put a supported one on the classpath. If you have the database settings to is loaded from a particular profiles you may need to active it (no profiles is currently Active).
2017-05-06 22:44:18.871 INFO 41648---[restartedmain] o.apache.catalina.core.standardservice:stopping service Tomcat
2017-05-06 22:44:18.902 INFO 41648---[Restartedmain] utoconfigurationreportlogginginitializer:

Error starting ApplicationContext. To display the Auto-configuration report re-run your application with ' debug ' enabled.
2017-05-06 22:44:18.907 ERROR 41648---[Restartedmain] o.s.b.d.loggingfailureanalysisreporter:

***************************
Application FAILED to START
***************************

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want a embedded database, put a supported one on the classpath. If you have the database settings to is loaded from a particular profiles you may need to active it (no profiles is currently Active).

This is because spring Boot defaults to loading the Org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration class, and the Datasourceautoconfiguration class uses the @Configuration annotations into Spring

Injected the DataSource bean. 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.

Because I just use spring boot to write some very simple examples to learn it, add @enableautoconfiguration on the application class (exclude={ Datasourceautoconfiguration.class})

Prevent spring boot from automatically injecting datasource beans

1  PackageCom.torlight;2 3 Importorg.springframework.boot.SpringApplication;4 Importorg.springframework.boot.autoconfigure.EnableAutoConfiguration;5 Importorg.springframework.boot.autoconfigure.SpringBootApplication;6 Importorg.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;7 ImportOrg.springframework.context.ApplicationContext;8 ImportOrg.springframework.context.ConfigurableApplicationContext;9 Ten  One /** A  * @since2017.05.06 -  * @authorAcer -  * the  */ - @SpringBootApplication - @EnableAutoConfiguration (Exclude={datasourceautoconfiguration.class}) -  Public classApplication { +      -      Public Static voidMain (string[] args) { +ApplicationContext appctx= springapplication.run (application.class, args); A          atSystem.out.println ("appctx.getbeandefinitioncount=" +Appctx.getbeandefinitioncount ()); -         Try { - ((Configurableapplicationcontext) appctx). Close (); -}Catch(Exception e) {/*Ignore*/ } -     } -}

spriing Boot Boot error: Cannot determine embedded database driver class for database type NONE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.