Java-访问在Windows Azure上运行的MongoDB服务器 [英] Java - Access to MongoDB server running on Windows Azure

查看:50
本文介绍了Java-访问在Windows Azure上运行的MongoDB服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用Windows Azure上运行的MongoDB的应用程序.此页面 http://www.mongodb.org/display/DOCS/MongoDB+onMongoDB上的+ Azure 是指VisualStudio解决方案,该解决方案具有帮助程序类,可用于访问mongo服务器设置以及部署/配置mongo实例.是否有基于Java的解决方案?

I am developing an application that will use MongoDB running on Windows Azure. This page http://www.mongodb.org/display/DOCS/MongoDB+on+Azure on MongoDB refers to a VisualStudio solution that has helper classes to get access to the mongo server settings and for deploying/configuring mongo instances. Is there a Java based solution?

推荐答案

开箱即用的10gen提供的解决方案只是.net/Visual Studio版本,该版本创建具有多个Worker Role实例的副本集.然后,您需要添加其他角色来运行您的应用程序(例如,Web角色中的基于IIS的Web应用程序,或工作角色中的基于Tomcat的Java应用程序).

Out of the box, the 10gen-provided solution is only a .net / Visual Studio version, which creates a Replica Set with several Worker Role instances. You'd then need to add additional Roles to run your app (such as an IIS-based web app in a Web Role, or a Tomcat-based Java app in a Worker Role).

您将遇到的问题:您需要:

The issue you'll run into: You'd need to:

  • 在Eclipse中进行Java开发
  • 生成WAR文件
  • 在visual Studio的工作人员角色"中创建Java scaffolding ,将Tomcat和JRE解压缩,将WAR文件复制到适当的目录,设置环境并启动Tomcat.
  • Do your Java development in Eclipse
  • Generate the WAR file
  • Create your java scaffolding in a Worker Role in visual Studio which unzips Tomcat and the JRE, copies your WAR file to the appropriate directory, sets up the environment, and launches Tomcat.

如果要完全放弃Visual Studio,则需要从Java启动脚本中配置并启动mongod.exe.从Eclipse创建Windows Azure项目时,您会看到有几个示例启动脚本:一个用于JBoss,一个用于Tomcat等.选择与您使用的脚本相匹配的脚本,并将其复制到主项目启动中脚本.然后,您可以对其进行自定义,以获取mongod.exe并启动它.创建一个独立的MongoDB实例应该非常简单,但是您将需要大量工作来构建副本集.10gen尚未为此目的构建现成的Java项目.

If you want to forego Visual Studio altogether, you'd need to configure and launch mongod.exe from your Java startup script. When you create a Windows Azure project from Eclipse, you'll see that there are several sample startup scripts: one for JBoss, one for Tomcat, etc. Pick the one that matches what you're using, copying it over the main project startup script. Then you can customize it to grab mongod.exe and launch it. This should be pretty straightforward to create a standalone MongoDB instance, but you'd have lots of work to construct a replicaset. 10gen doesn't have an out-of-the-box Java project built already for this.

这篇关于Java-访问在Windows Azure上运行的MongoDB服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆