Just working locally on a Windows machine, with a Java Spring Boot 3.1.0 app and a latest mongo db version, and getting failure when connecting the app with database.
The db is deployed locally with the next docker command:
docker run -d -p 27017:27017 --name mongo-db -e MONGO_INITDB_ROOT_USERNAME=adrian -e MONGO_INITDB_ROOT_PASSWORD=password -e MONGO_INITDB_DATABASE=documents mongo:latest
And the app has next connection properties to the database:
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=documents
spring.data.mongodb.username=adrian
spring.data.mongodb.password=password
spring.data.mongodb.authentication-database=admin
Or using uri:
spring.data.mongodb.uri=mongodb://adrian:password@localhost:27017/documents?authSource=admin
When any operation is performed through the database, this next error is printed:
org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='adrian', source='documents', password=<hidden>, mechanismProperties=<hidden>}
Also tried to create database manually after running the container, and then initializing the app, but the problem persists:
docker exec -it dd1b012c0e1a /bin/bash
use admin
db.auth('adrian', 'password')
use documents
Anyone knows, which is the source of the problem?