Error creating bean with name 'dataSource' defined in class path resource + Springboot

27,828

Exclude Datasource if you don't use database.

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

you see this link

Share:
27,828
Martin Erlic
Author by

Martin Erlic

Personal Portfolio: http://www.martinerlic.com/ GitHub: https://github.com/seloslav LinkedIn: https://www.linkedin.com/in/martin-erlic/ Hey! My name is Martin. I am an experienced Software Engineer and Product Developer with a demonstrated history of working in the computer software industry. I am currently located in Victoria, BC. I love bringing products to life, from napkin sketch to working prototype and beyond. While I enjoy working in a collaborative team environment, I have extensive experience building and shipping my own products to the Google PlayStore and Apple App Store from the ground up. Want to build something great? Feel free to get in touch. I am interested in partnering with startups and small businesses to help them create lightning fast, strategic web and app solutions to help them grow. Skilled in Cloud Software, Databases, API Integrations, Web & Mobile Applications and UI Design. Web, Android and iOS applications HTML, CSS, JavaScript, Java, .NET, Kotlin, Swift ReactJS, React-Native, Blazor, MongoDB, CosmosDB, Entity Framework, Realm, Parse-Server Strong engineering and business development professional with a Bachelor of Arts - BA focused in Economics from University of Victoria.

Updated on December 27, 2020

Comments

  • Martin Erlic
    Martin Erlic over 3 years

    I'm creating a Springboot application but will be using a external MongoDB over REST. My application properties file is very simple:

    application.properties

    # Server
    server.port=8081
    

    My global application file is also very simple. I make a connection to my externally hosted database with a Parse initialization method:

    @SpringBootApplication
    @ComponentScan(basePackages = {"com.test", "it.ozimov.springboot"})
    public class TmtApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(TmtApplication.class, args);
    
            // Database connection
            Parse.initialize("applicationId","restAPIKey", "https://parseapi.back4app.com");
    
        }
    }
    

    Why am I getting the following exception?

    Exceptions:

    Caused 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).
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
        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:202)
        at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
        at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
        ... 34 more
    Caused 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).
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
        ... 47 more
    Caused 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).
        at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.determineDriverClassName(DataSourceProperties.java:246)
        at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.initializeDataSourceBuilder(DataSourceProperties.java:183)
        at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration.createDataSource(DataSourceConfiguration.java:42)
        at org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Tomcat.dataSource(DataSourceConfiguration.java:56)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
        ... 48 more
    

    What don't I understand about Springboot? Is it looking for some kind of database initialization because it's running on Hibernate/Tomcat?