Spring boot + angular 2 Heroku deployment

后端 未结 3 1786
醉话见心
醉话见心 2021-02-06 18:22

I have a big issue. I\'m trying to deploy Spring Boot + Angular 2 web app on heroku but don\'t know how to do it. I tried several things including:

  • Making a

相关标签:
3条回答
  • 2021-02-06 18:35

    Use JHipster: https://jhipster.github.io

    Once installed, run:

    $ yo jhipster
    

    Then run

    $ yo jhipster:heroku
    
    0 讨论(0)
  • 2021-02-06 18:45

    If you deploy your app as a standard Java application, you can combine it with the Node.js buildpack to run ng build during the Heroku build.

    $ heroku buildpacks:add heroku/nodejs
    $ heroku buildpacks:add heroku/java
    $ git push heroku master
    

    The Node.js buildpack will detect your package.json, install Node.js and run npm. Then the Java build can proceed as normal.

    There is a guide for doing something very similar but with Grunt: Using Grunt with Java and Maven to Automate JavaScript Tasks

    0 讨论(0)
  • 2021-02-06 18:49

    The most simple way to do it:

    1. run ng build in angular 2 project root (if you are using angular-cli) and copy the content of dist folder to src/main/resources/static/.
    2. create Procfile (for maven):

      web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar

    3. commit and push changes.

      Also, you need spring-boot-starter-web present in dependencies. Which has embedded tomcat and automatically configured to serve static content from the static folder.

    0 讨论(0)
提交回复
热议问题