MongoDB链接:
data:
mongodb:
uri: mongodb://gdszfy:Gdszfy2018@127.0.0.1:27017/healthreports_new?authSource=admin
报错如下:
Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName=’’, source=‘test’, password=, mechanismProperties={}}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName=’’, source=‘test’, password=, mechanismProperties={}}"}
产生原因:连接不上是因为地址前面加了用户和密码gdszfy:Gdszfy2018,但是本地没有这个用户。
解决方法:只需要把“gdszfy:Gdszfy2018@”这一串字符去掉就可以了。
读懂配置文件的重要性,这就体现出来了。
在 MongoDB 中,你不需要创建集合。当你插入一些文档时,MongoDB 会自动创建集合。
Criteria类:可以看作传统sql的对象化表示Criteria 可以由session创建。