今天用springboot集成mongodb的时候报了一些错误

org.springframework.data.mongodb.UncategorizedMongoDbException: 
Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='zh',
source='main', password=<hidden>, mechanismProperties={}}; nested exception is
com.mongodb.MongoSecurityException: Exception authenticating
MongoCredential{mechanism=SCRAM-SHA-1, userName='zh', source='main',
password=<hidden>, mechanismProperties={}}
复制代码

这是我的配置文件

原因很简单,我用idea连接mongodb的插件上发现的,需要指定授权库以及授权机制

在uri后面加上 ?authSource=admin&authMechanism=SCRAM-SHA-1

mongodb://user:pwd@host:port/database?main?authSource=admin&authMechanism=SCRAM-SHA-1
复制代码

第二个

类型转换问题

我在这里使用了@Id注解 然后报了这个错

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.bson.types.ObjectId] to type [long]
复制代码

这个问题吗,我就懒得想了,直接用json接收了

太懒了!呜呜呜

分类:
阅读
标签: