spring項目整合mongodb進行開發:spring
MongoDB的性能指標:mongodb
100個併發,插入550萬條記錄的平均吞吐量:大約4100條/秒數據庫
MONGODB其實是一個內存數據庫,先將數據保存到內存,而後再寫入磁盤中spring-mvc
1.官網下載mongodb.
併發
https://www.mongodb.org/downloadsmvc
2.redhat上安裝好mongodb性能
3. spring中配置mongodb:測試
<?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/aop/spring-util.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd"> <mongo:mongo host="192.168.1.104" port="27017"/> <bean id = "mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg name="databaseName" value="mymongdb"/> <constructor-arg name="defaultCollectionName" value="xiejunbo"/> </bean> <bean id="person" class="com.mongo.dao.impl.PersonRepository"> <property name="mongoTemplate" ref="mongoTemplate"></property> </bean> <context:annotation-config /> </beans>
4. 編寫測試代碼:code