Spring Data MongoDB 配置



  <mongo:mongo-client host="127.0.0.1" port="27017">
    <mongo:client-options write-concern="NORMAL" />
  mongo:mongo-client>

     
    <mongo:mongo-client host="192.168.0.201" port="27017" credentials="tuzongxun:123456@mongoTest" id="mongo">    
       <mongo:client-options write-concern="SAFE"/>    
    mongo:mongo-client> 

如果用了write-concern=”SAFE”,必须要使用用户密码的方式,否则报错:
nested exception is java.lang.IllegalArgumentException: Credentials need to specify username!

你可能感兴趣的:(mongodb)