Spring support for MongoDB

Spring’s support for mongoDB includes the following features: The configuration of mongodb in spring supports the way of annotation @Configuration and xml MongoTemplate helper class extends Mongo The production efficiency of operations provides conversion between document and pojo types Add dependencies to pom.xml the the org.springframework.data the spring-data-mongodb 1.1.0.RELEASE You can set the log level to debug to view more log information log4j.category.org.springframework.data.document.mOngodb=DEBUG log4j.appender.stdout.layout.COnversionPattern=%d{ABSOLUTE} %5p %40.40c:%4L – %m%n app-mongodb.xml <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" the xmlns:cOntext=”http://www.springframework.org/schema/context” xmlns:mOngo=”http://www.springframework.org/schema/data/mongo” the xsi:schemaLocation=”http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-3.0.xsd   http://www.springframework.org/schema/data/mongo   http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd   http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd”> the <mongo:options connections-per-host="${mongo. connectionsPerHost}"       threads-allowed-to-block-for-connection-multiplier=”${mongo.threadsAllowedToBlockForConnectionMultiplier}”       connect-timeout=”${mongo.connectTimeout}”       max-wait-time=”${mongo.maxWaitTime}”       auto-connect-retry=”${mongo.autoConnectRetry}”       socket-keep-alive=”${mongo.socketKeepAlive}”       socket-timeout=”${mongo.socketTimeout}”       slave-ok=”${mongo. slaveOk}” write-number=”1″ write-timeout=”0″     write-fsync=”true” /> the the Person.java package com.dempe.summer.person.model; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; /** * @author: Zheng Dongping * @version 1.0 date: 2013-12-20 */ @Document(collection = “person”) public class Person { @Id private String id; private String name; private Integer age; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getAge() { return…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索