今天在用spring-data-mongo 配置mongodb的时候碰到个bug——com.mongodb.MongoQueryException: Query failed with error code 13。这个bug是说我鉴权没有通过,但我通过shell去访问是好的。
配置用的是spring官方的文档的配置:

<context:property-placeholder location="classpath:/com/myapp/mongodb/config/mongo.properties"/><mongo:mongo host="${mongo.host}" port="${mongo.port}"><mongo:optionsconnections-per-host="${mongo.connectionsPerHost}"threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}"connect-timeout="${mongo.connectTimeout}"max-wait-time="${mongo.maxWaitTime}"auto-connect-retry="${mongo.autoConnectRetry}"socket-keep-alive="${mongo.socketKeepAlive}"socket-timeout="${mongo.socketTimeout}"slave-ok="${mongo.slaveOk}"write-number="1"write-timeout="0"write-fsync="true"/>
</mongo:mongo><mongo:db-factory dbname="database" mongo-ref="mongo"/><bean id="anotherMongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"><constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean>

这里要说一下mongodb3.0以后鉴权的方式就改变了,所以之前安装mongodb可视化工具的时候也碰到鉴权不通过的问题,也是因为mongodb版本问题。所以通过以上这段xml配置鉴权的方式只能在mongodb3.0版本以前,3.0版本以后要用下面的配置。

    <context:property-placeholder location="classpath:mongo.properties" file-encoding="UTF-8"/><mongo:mongo-client id="mongo-client"  host="${mongo.host}" port="${mongo.port}" credentials="${mongo.username}:${mongo.password}@${mongo.database}"><mongo:client-options write-concern="1"/></mongo:mongo-client><mongo:db-factory id="mongoDbFactory" dbname="${mongo.database}" mongo-ref="mongo-client" /><bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">    <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>    </bean>

参考:http://stackoverflow.com/questions/30634987/com-mongodb-mongoqueryexception-query-failed-with-error-code-13

com.mongodb.MongoQueryException: Query failed with error code 13相关推荐

  1. 解决 win10 pycurl安装出错 Command python setup.py egg_info failed with error code 10 编译安装包 安装万金油...

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/yexiaohhjk/article/d ...

  2. python pip 报错 Command “python setup.py egg_info“ failed with error code 1 解决方法

    在执行 pip3 install scrapy 时遇到错误: Command "python setup.py egg_info" failed with error code 1 ...

  3. 成功解决Command quot;python setup.py egg_infoquot; failed with error code 1 in C:\Users\AppData\

    成功解决Command "python setup.py egg_info" failed with error code 1 in C:\Users\AppData\ 目录 解决 ...

  4. DNN出错:The compiler failed with error code 1.

    今天接手一个DNN网站,DNN网站的很多模块和管理功能页面都报这个错: Content is currently unavailable Error1 Error: Edit Content is c ...

  5. pip安装软件时出现Command python setup.py egg_info failed with error code 1 in /tmp/pip-build*的解决方案

    本文只提供本人的一些经验,不代表可以解决所有人的问题. pip安装软件时出现:Command "python setup.py egg_info" failed with erro ...

  6. 主产品清单位于oracle,OPatch failed with error code 73(OracleHomeInventory gets null oracleHomeInfo)...

    1.问题描述 [[email protected]_rac2 oraInventory]$/u01/app/oracle/product/11.2.0/dbhome_1/OPatch/opatch n ...

  7. pip安装软件 Command “python setup.py egg_info“ failed with error code 1 in

    本文只提供本人的一些经验,不代表可以解决所有人的问题. pip安装软件时出现:Command "python setup.py egg_info" failed with erro ...

  8. 解决 Command “python setup.py egg_info“ failed with error code 1 问题

    解决 Command "python setup.py egg_info" failed with error code 1 问题 参考文章: (1)解决 Command &quo ...

  9. 安装matplotlib时,报错Command “python setup.py egg_info“ failed with error code 1 in /tmp/pip-build-gvyzl2

    安装matplotlib 报错: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-b ...

最新文章

  1. Java将mysql输出csv,如何从Java中的Access数据库导出表并将其保存到.csv
  2. ​kdevelop用法_weixin_44594953的博客-CSDN博客_kdevelop​
  3. 大数据开发实战:Hive表DDL和DML
  4. Cisco产品线一览
  5. python 每次读一行-转载 python每次读入文件一行的问题(血的教训啊)
  6. 私有化预期终于落地,海尔智家将迎来更多可能!
  7. asp.net权限设置可能导致应用程序无法正常运行(转)
  8. sap.ui.viewModifications view extension
  9. [BZOJ4815][CQOI2017]小Q的表格 数论+分块
  10. CakePHP中文手册【翻译】
  11. Python接口自动化-接口基础(一)
  12. matlab工具箱使用50hz低通滤波器设计 和FFT 变化截取50hz工频信号幅值
  13. 电脑锁屏按什么键解锁_锁屏键除了锁屏还能干什么?这 6 个 App 带你玩转手机实体键...
  14. 2017.6.4 入门组 NO.4——猜数
  15. 全志 Allwinner V3S 开发环境搭建 (二)安装必要工具
  16. 两人互殴打架派出所如何处理
  17. python爬带用户名密码的网页_python爬虫:使用账号、密码和验证码登录知乎网页...
  18. Matplotlib中的plt和ax都是啥?
  19. e5408fc4a618ed2a663d0306def2cec3 (学生实验,谢谢)
  20. ssh连接的时候,出现“THE AUTHENTICITY OF HOST XXX CAN’T BE ESTABLISHED”警告

热门文章

  1. ARM CMSIS DAP源码分析
  2. html百度地图中心点不正确,关于网页调用百度地图定位不准的问题?
  3. 微信公众号服务器配置和php代码分析
  4. STM32程序编写总流程及技巧
  5. 双容水箱液位模糊PID控制系统设计与仿真(Matlab/Simulink)
  6. Windows 7 工行老版金邦达U盾安装解决方案
  7. 电脑优化导致打印机无法使用的问题
  8. 服务器2012r2系统安装设置,正确安装windows server 2012 r2的方法
  9. 腾讯云中cos的yml配置文件
  10. 2009美国电子/通信工程专业排名