mongo使用java-spring时用户验证配置方法
2016-09-17 11:53
801 查看
提示错误信息:com.mongodb.MongoQueryException: Query failed with error code 13 and error message 'not authorized for query on
参考网址:http://stackoverflow.com/questions/31503525/unable-to-connect-to-remote-mongo-db-for-2-days
mongo2.6配置用户验证,只需关注以下红色字体部分
<mongo:mongo-client
id="mongoClient"
replica-set="#{mongo[servers]}"
credentials="dbuser:dbpass@dbname}">
<mongo:client-options
connections-per-host="#{mongo[connections_per_host]}"
threads-allowed-to-block-for-connection-multiplier="5"
connect-timeout="#{mongo[connection_timeout]}"
max-wait-time="#{mongo[max_wait_time]}"
socket-keep-alive="#{mongo[socket_keepalive]}"
socket-timeout="#{mongo[socket_timeout]}"
write-concern="#{mongo[write_concern]}"/>
</mongo:mongo-client>
<mongo:db-factory
dbname="#{mongo[db_name]}"
mongo-ref="mongoClient"/>
参考网址:http://stackoverflow.com/questions/31503525/unable-to-connect-to-remote-mongo-db-for-2-days
mongo2.6配置用户验证,只需关注以下红色字体部分
<mongo:mongo-client
id="mongoClient"
replica-set="#{mongo[servers]}"
credentials="dbuser:dbpass@dbname}">
<mongo:client-options
connections-per-host="#{mongo[connections_per_host]}"
threads-allowed-to-block-for-connection-multiplier="5"
connect-timeout="#{mongo[connection_timeout]}"
max-wait-time="#{mongo[max_wait_time]}"
socket-keep-alive="#{mongo[socket_keepalive]}"
socket-timeout="#{mongo[socket_timeout]}"
write-concern="#{mongo[write_concern]}"/>
</mongo:mongo-client>
<mongo:db-factory
dbname="#{mongo[db_name]}"
mongo-ref="mongoClient"/>
相关文章推荐
- 使用反射创建Bean、Spring中是如何根据类名配置创建Bean实例、Java提供了Class类获取类别的字段和方法,包括构造方法
- 微信公众测试号使用Java Spring MVC,接口配置token验证。
- 使用反射创建Bean、Spring中是如何根据类名配置创建Bean实例、Java提供了Class类获取类别的字段和方法,包括构造方法
- spring data mongo用户验证配置
- 使用mongo-java-driver3.0.2.jar和mongodb3.0在java代码中的用户验证4
- AR系列路由器使用SSH用户验证方式为password登录路由器的典型配置
- Hibernate和ibatis在同一个webapp中混合使用在spring中的配置方法
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- Spring配置文件的三种方法(创建测试类Test.java)
- “回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。”的替代解决方法
- 使用Spring 来配置 hibernate 映射文件的 两种方法
- Hibernate和ibatis在同一个webapp中混合使用在spring中的配置方法
- 注解的力量 -----Spring 2.5 JPA hibernate 使用方法的点滴整理(四):使用 命名空间 简化配置
- Spring配置中transactionAttributes的使用方法和作用
- 注解的力量 -----Spring 2.5 JPA hibernate 使用方法的点滴整理(四):使用 命名空间 简化配置
- 回发或回调参数无效。在配置中使用 或在页面中使用 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。
- Spring的MVC模式I18N的配置及使用方法
- Spring中关于view层的一些配置和使用方法