Issue
Having a really annoying issue with my Spring Boot API.
So I have a MySQL db and a MongoDB which I connect to. Everything with the Mysql works fine i.e. the settings from the Application.yaml file but not Mongo. It ignores the Database name and creates its own one called "test". Even if I put in a random host and port it still connects locally. Anyone able to spot what i'm doing wrong?
server:
servlet:
contextPath: /api/v1/
port: 8080
spring:
data:
mongo.database: springboot-rest
mongo.host: localhost
mongo.port: 27017
output:
ansi:
enabled: ALWAYS
datasource:
url: jdbc:mysql://localhost:3306/spring_social?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
username: test
password: test
servlet:
multipart:
max-file-size: -1
max-request-size: -1
jpa:
show-sql: true
hibernate:
ddl-auto: update
naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
EDIT worth noting i also tied this way with no luck either:
spring:
data:
mongo:
database: springboot-rest
host: localhost
port: 27017
output:
ansi:
enabled: ALWAYS
datasource:
url: jdbc:mysql://localhost:3306/spring_social?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
username: test
password: test
Solution
mongodb should be there instead of mongo
spring:
data:
mongodb:
database: springboot-rest
Answered By - Nakul Goyal