简体   繁体   中英

How to deploy .war to heroku

I have made a dynamic web project on eclipse that starts on front end with index.html . I have tested it and it works on my local apache server. I have generated the war file. Now I want to deploy the war file to heroku. I have downloaded and installed everything. I checked the internet and I came to know about creating

pom.xml , a Main class to start execution , maven assembler jar file.

As a beginner I am not able to understand how to create these files and push them to heroku. Can someone please explain me ? I dont want to create a new heroku project.

There are two ways to deploy a war to Heroku:

  • Using the webapp-runner (or the similar jetty-runner)
  • Using the toolbelt deploy:war command

The preferred approach is using webapp-runner because it allows for more configuration of the container. Here is an article on using webapp-runner . The webapp-runner is a simple Tomcat container used to run your war file. In general, you add webapp-runner to your pom.xml , set your Procfile accordingly, and deploy to Heroku with git push .

The deploy:war approach is described in this article . It's somewhat outdated, and does not give you much in the way of configuration.

  1. Export war from eclipse.
  2. Login through your Heroku CLI.
  3. use this command to install heroku plugin heroku plugins:install heroku-cli-deploy
  4. Deploy with this command heroku war:deploy <path_to_war_file--app <app_name>

For more information please visit: https://devcenter.heroku.com/articles/war-deployment

I used successfully:

  1. heroku buildpacks:set heroku/java
  2. heroku buildpacks:clear
  3. heroku war:deploy target/routeplanner.war
  4. heroku logs --tail

I added to Procfile

buildpacks:clear
war:deploy target/routeplanner.war

and after

git push

Build and deploy completed. In log:

app[api]: Deploy a68256e8
app[api]: Build succeeded

But create the project URL returns Error: "in the application and your page could not be served"

In log: heroku[router]: at=error code=H14 desc="No web processes running"

But why do I have to request these commands again from console to reanimate application work?

  1. heroku buildpacks:clear
  2. heroku war:deploy target/routeplanner.war

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