简体   繁体   English

更改可在mongolab上与mongodb一起使用的应用程序

[英]change my application that works with mongodb on mongolab

I am working on Eclipse with a small scala/scalatra application.. at first I worked with mongodb installed on eclipse (locally) my application is running and everything is good but when I wanted to deploy my application on heroku I found http 503 error. 我正在使用小型scala / scalatra应用程序在Eclipse上进行工作。.最初,我使用在eclipse上安装的mongodb(本地)运行,并且应用程序运行良好,但一切都很好,但是当我想在heroku上部署应用程序时,发现http 503错误。

I think the problem is in my database, is what I need to change my connection with my base mongolab https://mongolab.com or should I add mongolab at heroku. 我认为问题出在我的数据库中,是我需要更改与基本mongolab https://mongolab.com的连接,还是应该在heroku中添加mongolab。

for connection mongodb I did: 对于连接mongodb我做了:

    val mongo = MongoConnection()
val coll = mongo("db_test")("tache2")

How can I change my code so I can have it connected to my account mongolab?? 如何更改代码,以便将其连接到我的帐户mongolab?

You should create your uri like this: 您应该这样创建uri:

val uri = MongoURI(s"mongodb://${username}:${password}@${host}:${port}/${dbname}")

def db: casbah.MongoDB = MongoConnection(uri)(dbname)

Note, this is using Casbah API. 注意,这是使用Casbah API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM