码迷,mamicode.com
首页 > 数据库 > 详细

spring mongodb用法

时间:2016-01-28 09:28:29      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:

A field annotated with @Id (org.springframework.data.annotation.Id) will be mapped to the ‘_id‘ field.
A field without an annotation but named ‘id‘ will be mapped to the ‘_id‘ field.

 

需要包括maven依赖

<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-commons</artifactId>
    <version>1.11.1.RELEASE</version>
</dependency>

 

spring配置

<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
    <property name="host" value="localhost"/>
</bean>

指定host。

参考

http://docs.spring.io/spring-data/data-mongo/docs/1.4.2.RELEASE/reference/html/mongo.repositories.html

http://docs.spring.io/spring-data/data-mongo/docs/1.8.1.RELEASE/reference/html/#mongo.repositories

http://docs.spring.io/spring-data/data-mongo/docs/1.8.1.RELEASE/reference/html/#mapping-conventions

 

http://docs.spring.io/spring-data/data-mongo/docs/1.4.2.RELEASE/reference/html/mongo.repositories.html

spring mongodb用法

标签:

原文地址:http://www.cnblogs.com/silvestris/p/5165154.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!