spring项目整合mongodb进行开发

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

相关文章
相关标签/搜索