连接MongoDB数据库属性文件
mongo.host=Mongodb连接地址
mongo.port=27017
mongo.poolSize=50
mongo.user=
mongo.password=
mongo.database=Mongodb数据库名字
spring配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="
http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:META-INF/conf/config.properties</value>
<value>classpath:META-INF/conf/jdbc.properties</value>
<value>classpath:META-INF/conf/dubbo.properties</value>
</list>
</property>
</bean>
<!-- MongoDB连接配置 -->
<mongo:mongo host="${mongo.host}" port="${mongo.port}" />
<mongo:db-factory dbname="${mongo.database}" mongo-ref="mongo" />
<bean id="mappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" />
<bean id="mappingMongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
<constructor-arg name="mappingContext" ref="mappingContext" />
<property name="typeMapper" ref="defaultMongoTypeMapper" />
</bean>
<bean id="defaultMongoTypeMapper" class="org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper">
<!-- 这里用来删除MongoDB中的_class属性,设置为空 -->
<constructor-arg name="typeKey">
<null />
</constructor-arg>
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory" />
<constructor-arg name="mongoConverter" ref="mappingMongoConverter" />
</bean>
</beans>
以上是放在spring配置文件中的,须引入spring-data-mongodb、
mongo-java-driver的JAR包
分享到:
相关推荐
数据库mongodb和navicat,navicat121_mongodb_cs_x64.exe和navicat121_mongodb_cs_x86.exe
mongodb for java api 英文版
mongodb4.0_64位 Linux和Windows, 官网下载有点慢,
可视化工具mongodb操作简单,可视化强 欢迎大家下载
MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_学习笔记MongoDB_...
MongoDB的_id自动增长.pdf 学习资料 复习资料 教学资源
通过python语言mongodb数据库惊醒操作,包括连接、上传、下载等操作
注意是英文的,MongoDB Architecture Guide,Mongodb 内部的架构介绍文档,很早以前官网下载到的,貌似现在很难找到了,也可以称为绝版了。
Spring-data-mongodb_1.9.4_API_docs
mongodb learn and design soul
用C#访问Mongo数据库,基础学习,上传文件保存至数据库
mongodb_consistent_backup, 对MongoDB集群或者副本集执行一致备份的工具 一致性备份工具- mongodb-consistent-backup 使用可选的归档,压缩/复制,加密和上传功能,为MongoDB创建一致的point-in-time备份这个工具的...
mongodb_java_driver 已经验证可用!
Data-Unit_MongoDB_Restore适用于磁盘存储故障、勒索病毒删除、误操作删除等导致的数据库丢失恢复。运行工具后将数据文件拖入本窗口即可。也支持扫描分区和裸磁盘,建议扫描磁盘镜像文件,效果更好。 免费版每个集合...
使用C#语言对mongo数据库进行查询,并支持导出excel
MongoDB_权威指南_中文版,压缩包文件,欢迎下载。11111
MongoDB_The_Definitive_GuideMongoDB_The_Definitive_GuideMongoDB_The_Definitive_Guide
mongodb manager,mongodb 客户端工具,连接mongodb数据库~~~~~~~~~~~