数码资讯
Spring Data MongoDB 配置
选购提示
关注价格、性能、续航、售后和真实使用场景,理性比较后再下单。
<!-- 不需要密码验证的配置方式 --> <mongo:mongo-client host="127.0.0.1" port="27017"> <mongo:client-options write-concern="NORMAL" /> </mongo:mongo-client> <!-- spring连接mongodb数据库的配置 需要密码验证的方式 tuzongxun:123456@mongoTest 对应用户,密码 数据库 --> <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!
声明:本文内容用于数码产品信息整理与选购参考,具体价格、库存、售后政策以官方渠道和电商页面实时信息为准。