How do I deploy an angular2 app on a local tomcat server?

前端 未结 2 981
长情又很酷
长情又很酷 2021-01-06 16:08

I have been developing an angular2 app with the lite server. Now I would like to deploy this app on a tomcat server to connect with a java backend. I have been using angular

相关标签:
2条回答
  • 2021-01-06 17:03

    Generate the dist folder using ng build --environment=prod and copy the dist folder contents into tomcat /opt/tomcat/webapps/ROOT/ folder.

    When we hit the http://localhost:8080/ in the browser then automatically index.html file will be loaded.

    Thanks

    0 讨论(0)
  • 2021-01-06 17:05

    I'm running a little script to build the project and then copy it to tomcat. I'm telling angular what the base directory is that it will run under in tomcat.

    #!/bin/sh
    ng build --base-href /angular/ --prod
    mkdir -p /home/xxx/apache-tomcat-8.0.37/webapps/angular
    cp -R /home/xxx/angular-clitest/dist/* /home/xxx/apache-tomcat-8.0.37/webapps/angular/
    

    Once thats run, start tomcat and you can access it at: http://localhost:8080/angular

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