Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve the 'Factory method 'mongoDatabaseFactory' threw exception with message: Database name must not be empty' error in Spring Boot?

Error creating bean with name 'mongoDatabaseFactory' defined in class path resource. Failed to instantiate [org.springframework.data.mongodb.core.MongoDatabaseFactorySupport]: Factory method 'mongoDatabaseFactory' threw exception with message: Database name must not be empty

I'm not sure what I'm doing wrong here.

error message

application.properties

I can't seem to figure out how to get rid of this message. I have a DB name set in the application.properties. I have MongoDB running and I'm still getting this every time I try to start my server.

like image 854
smlksmth Avatar asked Sep 06 '25 00:09

smlksmth


1 Answers

Just your fellow learner here, following the same tutorial.

I jumped to the documentation and it seems you just have to add /movie-api-db at the end of your URI, to get access to the database collection:

spring.data.mongodb.uri=mongodb+srv://<username>:<pwd>@<cluster>.mongodb.net/movie-api-db

Hope, it'll help!

like image 150
BadassBilal Avatar answered Sep 07 '25 15:09

BadassBilal