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

前端 未结 28 2639
天命终不由人
天命终不由人 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条回答
  •  旧时难觅i
    2020-11-30 20:57

    It simply means you have downloaded a spring starter code with database dependency without configuring your database. So it doesn't know how to connect. For Spring boot version 2.18 do the below steps to fix it.

    1. Create a database for the driver you have downloaded ie mysql/mongo etc.
    2. In your applications.properties file add the db connection info. Sample is given for mysql if your db is mongo change it for mongo.

      spring.datasource.url=jdbc:mysql://localhost:3306/db_name_that_you_created spring.datasource.username=your_db_username_here spring.datasource.password=your_db_pass_here spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.jpa.database-platform = org.hibernate.dialect.MySQL5Dialect spring.jpa.generate-ddl=true spring.jpa.hibernate.ddl-auto = update

    3. Reboot the server it will be running.

提交回复
热议问题