Deploy WAR project on Heroku
Pre Requisites :
- A War File created for your project (Follow steps in Eclipse :=> File -> Export -> Web -> WAR file)
- Heroku Account.
There are several ways to deploy app on Heroku but common
methods have been discussed in this blog:
- Deploy your code to Git and then push the code to Heroku (by using command> git push Heroku master).Upload everything onto a git repository so that you can easily push to Heroku repository. Use below directory structure:
- pom.xml
- Procfile
- src/main/java/root - Demo.java
- src/main/resources - mywebapp.jar
- Deply the code directly from Heroku toolbelt(i.e. by using Command prompt) to Heroku Web Application container
- Deploy the Heroku app directly from Ecplise project. Firstly you need to setup the Heroku plugin into Eclipse.
Install Heroku-deploy CLI Plugin using command >heroku plugins:install https://github.com/heroku/heroku-deploy
a.
Create a Heroku application using command> ‘heroku
create’
b.
To deply the project war use command> ‘heroku
deploy:war –war <absolute path to war file> --app <app_name>’
c.
Use ‘heroku open’ to open app in browser’
Steps for configuration of
Heroku into Eclipse
a.
After opening Eclipse, Go to Help> Install
new Software.
b.
Add a plugin by providing it a name as ‘Heroku’
and location as ‘https://eclipse-plugin.herokuapp.com/install’.
c.
Add this site and tick the checkbox ‘Heroku
Eclipse Integration’.
API Key Setup for Heroku
a.
Open Eclipse>Preferences.
b.
Choose Heroku and enter Heroku username in Email
field, Password in Password field (After succesfull login API key in API key will
be populated).
c.
Click Login.
To Deploy through Eclipse
a.
Right click your project, go to Team>Commit.
Enter a proper commit message and add the files to the commit
b.
Right click the Project>Team>Push to
Upstream. Heroku will perform the build based on type of app and deploy the app
on Heroku on successful build.
No comments:
Post a Comment