title: How to set MongoDB ReadPreference in Spring MVC's contextConfigLocation
body: <p>I am connecting to a MongoDB sharding server via mongodb java driver in Spring MVC. I am using the following versions:</p>
  
  <ul>
  <li>spring-webmvc-3.2.1.RELEASE</li>
  <li>mongo-java-driver/2.10.0/mongo-java-driver-2.10.0</li>
  <li>spring-data-mongodb-1.2.0.RELEASE</li>
  </ul>
  
  <p>My Mongo options are set in the contextConfigLocation file mvc-dispatcher-servlet.xml</p>
  
  <pre><code>&lt;mongo:mongo host="mongo.sample.com" port="30000"&gt;
       &lt;mongo:options auto-connect-retry="true"
                      slave-ok="true"/&gt;
  &lt;/mongo:mongo&gt;
  </code></pre>
  
  <p>It works pretty well, but the slave-ok is deprecated by come.MongoDB.ReadPreference.  I just wonder if there is any way to set the readPreference for Spring MVC in the contextConfiLocation file.</p>