1,首先看配置文件 mongo-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/data/mongo
http://www.springframework.org/scheme/data.mongo.spring-mongo-1.8.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<mongo:mongo-client id="testMongo" host="${mongo.test.host}" port="${mongo.test.port}"
replica-set="${mongo.test.replica-set}"
credentials="${mongo.test.authority}">
<mongo:client-options
connections-per-host="${mongo.test.connectionsPerHost}"
threads-allowed-to-block-for-connection-multiplier="${mongo.test.threadsAllowedToBlockForConn