Spring Boot + Angular 2结构 [英] Spring Boot + Angular 2 structure
问题描述
在我的项目中,我想使用 Spring Boot
和 Angular 2.
In my project I want to use Spring Boot
and Angular 2.
-
Spring Boot App
的结构是通过 Spring Initializer 完成的. -
Angular 2 App
的结构由Angular CLI
工具(ng new myfrontendapp
) 完成
- Structure of
Spring Boot App
is done from Spring Initializer. - Structure of
Angular 2 App
is done byAngular CLI
tool (ng new myfrontendapp
)
在 Angular 1
中,您可以将 index.html
放入公用文件夹中.
在 Angular 2
中,在 src
文件夹中生成 index.html
,我想保留该结构.
我的问题是应该如何显示 Spring Boot
的 index.html
并保持生成的结构 Angular CLI.
My question is what should I do to make index.html
visible for Spring Boot
and keep the structure generated by Angular CLI.
感谢您的回答.
推荐答案
解决方案是将Angular 2项目的构建输出重新定位到Spring Boot /static 或/public 文件夹.
Solution is to relocate build output of an Angular 2 project into Spring Boot /static or /public folder.
2个步骤:
2 Steps:
- 在 .angular-cli.json 文件中设置 outDir :
- Set the outDir in .angular-cli.json file:
-
Angular 2项目根目录中的
-
ng build
(!请注意,这适用于 在Angular CLI工具中生成的Angular 2项目,对于不是由Angular CLI工具outDir创建的Angular 2项目在 tsconfig.json 文件)
(! Please note that this works for Angular 2 project generated in Angular CLI tool, for Angular 2 project not created by Angular CLI tool, the outDir is edited in tsconfig.json file )
这篇关于Spring Boot + Angular 2结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!