1、报错:
Caused by: com.mongodb.MongoSecurityException: Exception authenticating MongoCredential
2、原因:
application.yml文件配置MongoDB,它的password不能使用纯数字密码
3、环境:
springboot项目中,使用mongodb数据库
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
4、配置文件:
# 配置应用服务端口号
server:
port: 9002
# 配置应用服务名称
spring:
application:
name: lcn-course-manager
data:
mongodb:
host: 10.1.1.74
port: 27017
authentication-database: admin
username: root
# 密码不能使用纯数字
# 报错com.mongodb.MongoSecurityException
password: tom
database: lcn
# 配置数据源
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://10.1.1.74:3306/tx_lcn?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8
username: root
password: 123456
# 配置eureka注册中心连接信息
eureka:
client:
service-url:
defaultZone:
- http://localhost:8761/eureka/
# TX-LCN中的transaction client配置信息
tx-lcn:
client:
# 配置TM的位置,及TM事务消息端口
manager-address: 127.0.0.1:8070