Spring Boot Mongo 配置被 application.yaml 忽略
SpringBoot Mongo config being ignore by application.yaml
我的 Spring 引导 API 有一个非常烦人的问题。
所以我有一个 MySQL 数据库和一个 Mongo 我连接的数据库。 Mysql 的所有内容都工作正常,即来自 Application.yaml 文件但不是 Mongo 的设置。它忽略数据库名称并创建自己的名称“test”。即使我放入一个随机主机和端口,它仍然在本地连接。任何人都能发现我做错了什么?
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 值得注意的是,我也以这种方式打成平局,但也没有运气:
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
mongodb 应该在那里而不是 mongo
spring:
data:
mongodb:
database: springboot-rest
我的 Spring 引导 API 有一个非常烦人的问题。
所以我有一个 MySQL 数据库和一个 Mongo 我连接的数据库。 Mysql 的所有内容都工作正常,即来自 Application.yaml 文件但不是 Mongo 的设置。它忽略数据库名称并创建自己的名称“test”。即使我放入一个随机主机和端口,它仍然在本地连接。任何人都能发现我做错了什么?
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 值得注意的是,我也以这种方式打成平局,但也没有运气:
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
mongodb 应该在那里而不是 mongo
spring:
data:
mongodb:
database: springboot-rest