Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured

前端 未结 28 2535
天命终不由人
天命终不由人 2020-11-30 19:57

I am working on a Spring Boot Batch example with MongoDB and I have already started the mongod server.

When I launch my application, I

28条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 20:52

    This link helped.

    Spring Boot auto-configuration tries to configure beans automatically based on the dependencies added to the classpath. And because we have a JPA dependency (spring-data-starter-jpa) on our classpath, it tries to configure it.

    The problem: Spring boot doesn't have the all the info needed to configure the JPA data source i.e. the JDBC connection properties. Solutions:

    1. provide the JDBC connection properties (best)
    2. postpone supplying connection properties by excluding some AutoConfig classes (temporary - should be removed eventually)

    The above link excludes the DataSourceAutoConfiguration.class with

    @SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
    

    But this didn't work for me. I instead, had to exclude 2 AutoConfig classes:

    @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, XADataSourceAutoConfiguration.class})
    

提交回复
热议问题