Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified

后端 未结 12 1588
逝去的感伤
逝去的感伤 2020-12-23 16:39

I have created a basic spring boot application from SPRING INITIALIZR with the Web, MongoDB and JPA dependencies.

When I try to run the spring boot

相关标签:
12条回答
  • 2020-12-23 16:51

    Go to resources folder where the application.properties is present, update the below code in that.

    spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
    
    0 讨论(0)
  • 2020-12-23 16:52

    In gradle build i simply:

    compile('org.springframework.boot:spring-boot-starter-data-jpa') compile('org.springframework.boot:spring-boot-starter-security') compile('org.springframework.boot:spring-boot-starter-web') compile('org.springframework.boot:spring-boot-devtools')

    removed

    **`compile('org.springframework.boot:spring-boot-starter-data-jpa')`**
    

    and it worked for me.

    0 讨论(0)
  • 2020-12-23 16:55

    This error occurred when you are putting JPA dependencies in your spring-boot configuration file like in maven or gradle. The solution is: Spring-Boot Documentation

    You have to specify the DB connection string and driver details in application.properties file. This will solve the issue. This might help to someone.

    0 讨论(0)
  • 2020-12-23 16:57

    Add the line below in application.properties file under resource folder and restart your application.

    spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
    
    0 讨论(0)
  • 2020-12-23 16:58

    I encountered this error simply because I misspelled the spring.datasource.url value in the application.properties file and I was using postgresql:

    Problem was: jdbc:postgres://localhost:<port-number>/<database-name>

    Fixed to: jdbc:postgresql://localhost:<port-number>/<database-name>

    NOTE: the difference is postgres & postgresql, the two are 2 different things.

    Further causes and solutions may be found here

    0 讨论(0)
  • 2020-12-23 17:01

    adding org.apache.derby dependency solved my issue.

    <dependency>
                <groupId>org.apache.derby</groupId>
                <artifactId>derby</artifactId>
                <scope>runtime</scope>
            </dependency>
    
    0 讨论(0)
提交回复
热议问题