简体   繁体   English

Angular 2应用程序与Java构建集成

[英]Angular 2 app integrate with Java build

Am working on a Angular 2 app (Angular CLI) with Java back end. 我正在使用Java后端开发Angular 2应用程序(Angular CLI)。 I do a MVN clean install and this grabs all the file from my angular app and builds it under 'target' folder. 我进行了MVN全新安装,这从我的角度应用程序中抓取了所有文件,并将其构建在“目标”文件夹下。 How do I tell my app to server from the target folder? 如何将我的应用程序从目标文件夹告诉服务器? at the moment when i run 'npm serve' it executes Dev server. 当我运行“ npm serve”时,它将执行开发服务器。

For production, surely you want to use something like Apache WebServer or NGINX for hosting your built Angular-App. 对于生产而言,您肯定要使用Apache WebServer或NGINX之类的东西来托管您构建的Angular-App。

For testing the output that was built in /target locally, you can navigate to your Angular-project's directory and do: 为了测试本地/target中内置的输出,您可以导航到Angular-project的目录并执行以下操作:

npm install --save-dev http-server

then you add to package.json the command 然后将命令添加到package.json

"start-production-build": "http-server ./target -c-1 -p 1337",

and now you can do 现在你可以做

npm run start-production-build

and open your browser on localhost:1337 并在localhost:1337上打开浏览器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM