简体   繁体   中英

How will I host multiple spring boot web applications which share the same Mysql database to Heroku?

I have implemented an E-commerce site, having 2 spring boot web applications, one for admin and another for customer. Both of the applications use the same Mysql Db. How will I host both my applications and DB on Heroku.

I am an absolute beginner and would like to know if there is any way to achieve this as the standard Heroku supports one app-one repo use case only. And after some research I found out it is possible to share DB between Heroku apps using shared add-ons but don't know how.

It will be great if someone please brief me the steps to achieve the same.

You can have your www pointing to one app (see the settings for domains configuration) and an admin subdomain pointing to the admin app. So, two heroku apps. Now, your priority is the ecommerce, so you should create the database addon there.

All resources in heroku work with the concept of attachment. The addon exists somewhere and it's attached to your app by exporting environment variables there.

Now that you've created your database in the ecommerce app, you can share that same database with the admin app. Check the docs:

https://devcenter.heroku.com/articles/heroku-postgresql#sharing-heroku-postgres-between-applications

heroku addons:attach ecommerce-app-name::DATABASE --app admin-app-name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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