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

前端 未结 28 2524
天命终不由人
天命终不由人 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:36

    If you added "spring-boot-starter-data-jpa" dependency in pom.xml, Please add respective database in dependency like h2 and etc.

    0 讨论(0)
  • 2020-11-30 20:37

    For me the resource folder was getting excluded on a maven update/build. I went to Build Path>Source and found that src/main/resources have "Excluded **". I removed that entry (Clicked on Excluded **>Remove>Apply and Close).

    Then it worked fine.

    enter image description here

    0 讨论(0)
  • 2020-11-30 20:38

    Excluding the DataSourceAutoConfiguration.class worked for me:

    @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
    
    0 讨论(0)
  • 2020-11-30 20:39

    If datasource is defined in application.resources, make sure it is locate right under src/main and add it to the build path.

    0 讨论(0)
  • 2020-11-30 20:40

    I meet same error when start a new project. Use command line works for me.

    ./gradlew bootRun
    
    0 讨论(0)
  • 2020-11-30 20:41

    “Failed to configure a DataSource” error. First, we fixed the issue by defining the data source. Next, we discussed how to work around the issue without configuring the data source at all.

    https://www.baeldung.com/spring-boot-failed-to-configure-data-source

    0 讨论(0)
提交回复
热议问题