您的位置:首页 > 数据库 > Mongodb

spring mongodb用法

2016-01-28 09:00 513 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: