简体   繁体   English

使用 ObjectRocket 插件将带有 MongoDB 应用程序的 jHipster 部署到 Heroku

[英]Deploying a jHipster with MongoDB app to Heroku, with ObjectRocket addon

I have created a jHipster application that uses a MongoDB database.我创建了一个使用 MongoDB 数据库的 jHipster 应用程序。 I am trying for the last few days to deploy it on Heroku.最近几天我正在尝试将它部署在 Heroku 上。 I've run the heroku generator as required.我已经根据需要运行了 heroku 生成器。 "jhipster heroku". “jhipster heroku”。 I also pushed the code to the heroku branch with "git push heroku master".我还使用“git push heroku master”将代码推送到 heroku 分支。 However, I still have a problem.但是,我仍然有一个问题。

Caused by:造成的:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoDbFactorySupport]: Factory method 'mongoDbFactory' threw exception; org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.data.mongodb.core.MongoDbFactorySupport]:工厂方法'mongoDbFactory'抛出异常; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongo' defined in class path resource [org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class]: Bean instantiation via factory method failed;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 class 路径资源 [org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class] 中定义名称为“mongo”的 bean 创建时出错:通过工厂方法进行 Bean 实例化失败; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.mongodb.MongoClient]: Factory method 'mongo' threw exception;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [com.mongodb.MongoClient]:工厂方法 'mongo' 抛出异常; nested exception is java.lang.IllegalArgumentException: The connection string is invalid.嵌套异常是 java.lang.IllegalArgumentException:连接字符串无效。 Connection strings must start with either 'mongodb://' or 'mongodb+srv://连接字符串必须以 'mongodb://' 或 'mongodb+srv://' 开头

I do realize that I have to place the MongoDB connection string, provided by the ObjectRocket addon, somewhere in the.yml files, but I am not sure where.我确实意识到我必须将 ObjectRocket 插件提供的 MongoDB 连接字符串放在 .yml 文件中的某个位置,但我不确定在哪里。 This is not a duplicate of Deploying a JHipster/MongoDB application to Heroku because that question was asked 5 years ago and since then, Heroku provided a subgenerator for MongoDB apps on Heroku. This is not a duplicate of Deploying a JHipster/MongoDB application to Heroku because that question was asked 5 years ago and since then, Heroku provided a subgenerator for MongoDB apps on Heroku. Also, should I modify the Profile somehow?另外,我应该以某种方式修改个人资料吗?

Thanks a lot for the help!非常感谢您的帮助!

JHipster should have generated a application-heroku.yml under src/main/resources . JHipster 应该在src/main/resources下生成了一个application-heroku.yml It should contain the spring data property for the mongo db connection ( spring.data.mongodb.uri ).它应该包含 mongo db 连接的 spring 数据属性( spring.data.mongodb.uri )。 You should replace the value with your object rocket connection string.您应该使用 object 火箭连接字符串替换该值。

Side note, why you have the errors message: JHipster uses only add-ons with a free tier.旁注,为什么您会收到错误消息:JHipster 仅使用带有免费层的附加组件。 For mongo db it was mLab's addon.对于 mongo db,它是 mLab 的插件。 Sadly it has been discontinued.可惜已经停产了。 There is an open issue to update JHipster's heroku integration accordingly.有一个未解决的问题需要相应地更新 JHipster 的 heroku 集成。 https://github.com/jhipster/generator-jhipster/issues/13424 https://github.com/jhipster/generator-jhipster/issues/13424

I managed to solve it finally.我终于设法解决了。 I suspected it due to the application-heroku.yml file.由于 application-heroku.yml 文件,我怀疑它。 But this was not the only problem for me.但这不是我唯一的问题。 The main problem was that I didn;t knew I have to edit the Procfile also.主要问题是我不知道我还必须编辑 Procfile。 Tip for anyone that lands here.给任何在这里登陆的人的小费。 You should check that the Procfile is also edited with the database name.您应该检查 Procfile 是否也使用数据库名称进行了编辑。

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

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