日期:2014-05-16 浏览次数:20537 次
参照Spring官方文档中Spring-data-mongodb对Mongodb的操作,做了一个简单的示例,以防遗忘。
文档地址:http://docs.spring.io/spring-data/data-mongodb/docs/1.4.0.RELEASE/reference/html/
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>lee.forum</groupId> <artifactId>Forum1.0.1</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <!--========================================================== --> <!--======================= 测试 ========================== --> <!--========================================================== --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.8.2</version> <scope>test</scope> </dependency> <!--=========================================================== --> <!--======================= Spring ========================== --> <!--=========================================================== --> <!-- Spring-data --> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-mongodb</artifactId> <version>1.3.4.RELEASE</version> </dependency> <!-- Spring core beans tx context expression test --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.2.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.2.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.2.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.2.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>3.2.8.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>3.2.8.RELEASE</version> </dependency> <!--=========================================================== --> <!--======================== Mongodb ========================== --> <!--=========================================================== --> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>2.11.4</version> </dependency> <!--=========================================================== --> <!--======================== Logs ========================== --> <!--=========================================================== --> <dependency> <groupId>org.slf4j</gr