mongo db - 无法使用副本集启动 Mongo
我正在使用版本 spring-data-mongo 版本 1.0.0.M4 - 迄今为止的最新版本。
我这样定义我的bean:
<bean id="mongoOps" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo" />
<constructor-arg name="databaseName" value="my_mongo" />
</bean>
<mongo:mongo id="mongo" replica-set="host1:27017,host2:27018,host3:27019" >
<mongo:options... />
</mongo:mongo>
但是当我启动我的服务器时,它会尝试连接到我的计算机上的默认主机和端口,发生这种情况是因为在 MongoFactoryBean 第 93 行中它说:
if (host == null) {
logger.debug("Property host not specified. Using default configuration");
mongo = new Mongo();
} else {...
//do all the stuff I want to be done...
}
那么我如何使用副本集定义我的 Mongo设置主机?
谢谢你!
I'm using version spring-data-mongo version 1.0.0.M4 - the latest version to this date.
I defined my bean like this:
<bean id="mongoOps" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo" />
<constructor-arg name="databaseName" value="my_mongo" />
</bean>
<mongo:mongo id="mongo" replica-set="host1:27017,host2:27018,host3:27019" >
<mongo:options... />
</mongo:mongo>
But when I start my server it try's to connect to the default host and port on my computer, this happens because in MongoFactoryBean line 93 it says:
if (host == null) {
logger.debug("Property host not specified. Using default configuration");
mongo = new Mongo();
} else {...
//do all the stuff I want to be done...
}
So how can I define my Mongo with a replica-set without setting the host?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
bean 声明不应该像这样吗 - 也许您缺少复制集 bean 的 ID?
Shouldn't the bean declaration be like this - possibly you're missing the ID of the replicaset bean?
<mongo:mongo id="replicaSetMongo" replica-set="host1:27017,host2:27018"/>