spring web项目mongoTemplate配置

最近在写一个hive相关的自动化管理框架,想把hql文件、udf文件、查询记录以及运行日志等保存起来,使用mongo作为存储仓库,为了简单,使用spring-data-mongodb作为orm框架,配置方式如下:

1. 在applicationcontext.xml或者beanRefContext.xml等定义bean的地方,配置


connections-per-host="${mongo.connectionsPerHost}"
threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}"
connect-timeout="${mongo.connectTimeout}"
max-wait-time="${mongo.maxWaitTime}"
auto-connect-retry="${mongo.autoConnectRetry}"
socket-keep-alive="${mongo.socketKeepAlive}"
socket-timeout="${mongo.socketTimeout}"
slave-ok="${mongo.slaveOk}"
write-number="${mongo.writeNumber}"
write-timeout="${mongo.riteTimeout}"
write-fsync="${mongo.writeFsync}"/>


2. 在spring的classpath下面,配置mongo.properties:
mongo.replicaSet=localhost:30001
mongo.connectionsPerHost=8
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.connectTimeout=1000
mongo.maxWaitTime=1500
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.socketTimeout=1500
mongo.slaveOk=true
mongo.writeNumber=1
mongo.riteTimeout=0
mongo.writeFsync=true

你可能感兴趣的:(存储)