Spring Boot + Angle 2 Heroku部署 [英] Spring boot + angular 2 Heroku deployment
问题描述
我有一个大问题.我正在尝试在heroku上部署Spring Boot + Angular 2 Web应用程序,但不知道该怎么做.我尝试了几件事,包括:
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:
-
制作.war文件并将其部署到heroku(来源将项目部署为标准Java应用程序(来源此处)
Deploying project as standard java application (source here)
但是这些都不起作用.第一次尝试没有用,因为我一直找不到404,而第二次尝试没有用,因为我认为在Procfile中描述的位置中找不到一些jar文件.任何人都可以给我链接,示例,或者写逐步说明来实现此目的.谢谢你.
but none of these worked. The first attempt didn't work because I constatly got 404 not found, and the second one didn't work due to, I think, some jar file wasn't found in the location which was described in the Procfile. Can anyone give me a link, an example, or write a step by step instruction how to achieve this. Thank you.
推荐答案
最简单的方法:
- 在angular 2项目根目录中运行
ng build
(如果您使用angular-cli),然后将dist文件夹的内容复制到src/main/resources/static/. -
创建Procfile(用于Maven):
- 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/. create Procfile (for maven):
网站:java $ JAVA_OPTS -Dserver.port = $ PORT -jar target/*.jar
web: java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar
提交并推送更改.
此外,您还需要依赖项中包含spring-boot-starter-web.已嵌入tomcat并自动配置为从静态文件夹中提供静态内容.
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.
这篇关于Spring Boot + Angle 2 Heroku部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 在angular 2项目根目录中运行