spring + mongodb 整合 Nosql mongodb 数据库配置文件

本文介绍了Spring与MongoDB的整合过程,展示了Nosql数据库的配置文件,期待专业人士解析其详细配置步骤。
摘要由CSDN通过智能技术生成

下图是Spring整合mongodb Nosql数据库的配置文件,具体配置楼主也不是很清楚,希望大神给与指点:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans  
						http://www.springframework.org/schema/beans/spring-beans.xsd  
						http://www.springframework.org/schema/context  
						http://www.springframework.org/schema/context/spring-context.xsd  
						http://www.springframework.org/schema/aop 
						http://www.springframework.org/schema/aop/spring-aop.xsd">
							
    <bean id="mongoOptions" class="org.springframework.data.mongodb.core.MongoClientOptionsFactoryBean">
    	<property name="connectionsPerHost" value="8"></property>
    	<property name="threadsAllowedToBlockForConnectionMultiplier" value="4"></property>
    	<property name="connectTimeout" value="1000"></property>
    	<property name="maxWaitTime" value="1500"></property>
    	<property name="socketKeepAlive" value="true"></property>
    	<property name="socketTimeout" value="1500"></property>
    </bean>

    <bean id="mongo" class="org.springframework.data.mongodb.core.MongoClientFactoryBean">
    	<property name="mongoClientOptions" ref="mongoOptions"></property>
    	<property name="host" value="${mongodb.host}"></property>
    	<property name="port" value="${mongodb.port}"></property>
    </bean>
    
    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
        <constructor-arg ref="mongo" />
        <constructor-arg name="databaseName" value="${mongodb.dbName}" />
    </bean>
    
</beans>
不忘初心,方得始终!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值