How to deploy angular2 to tomcat?

First, I would like to describe my setup:

I have a web service, let’s call it “Cars” written in Java, which I tested in eclipse with tomcat v6, working locally (this was a requirement, so when it works locally, I can switch to running it with " real "tomcat server so others can access). It works, it accesses the database, it offers an answer for specific URIs, etc.

I encoded the angular 2 application, "WebCar" in Plunker, and now I want to run it on my computer with a Tomcat server (if there is no better way to do this, I was told to do it with Tomcat. Since I do not know a better option, why I constantly talking about tomcat). With eclipse, I already managed to launch the application using the palantir plugin for typescript https://marketplace.eclipse.org/content/typescript , and then run the project with server-launch.js, which contains require('lite-server'); , this allows me to see what I saw on plunker, so it works, but before I upload anything to the business servers, I wanted to check everything (therefore, a setting that might not be needed, but that’s what I invented).

Now I want to take one more step and use, if possible, tomcat v6 to run my angular 2 application , instead of just using this Lite server so that I can check that it works , and then upload it to the “real”, remote server .

I would like to know what options exist, which would be better, and all that is required to properly deploy angular 2. So far I have found this

So maybe the question should be (I don’t know for sure): As soon as you get your angular 2 code, what's next?

Btw there are a few other stackOverflow questions similar to this, but as far as I have seen, no answer at all or with answers only indirectly related to this (and, of course, nothing like a guide or step by step)

+5
source share
1 answer

Thanks to @nuzz for this.

I run a little script to create a project and then copy it to tomcat. I tell angular what the base directory will be running 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 this starts, run tomcat and you can access it: http: // localhost: 8080 / angular

+3
source

All Articles