Spring Boot + Angular 2结构 [英] Spring Boot + Angular 2 structure

查看:97
本文介绍了Spring Boot + Angular 2结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我想使用 Spring Boot Angular 2.

In my project I want to use Spring Boot and Angular 2.

  1. Spring Boot App 的结构是通过 Spring Initializer 完成的.
  2. Angular 2 App 的结构由 Angular CLI 工具(ng new myfrontendapp)
  3. 完成
  1. Structure of Spring Boot App is done from Spring Initializer.
  2. Structure of Angular 2 App is done by Angular 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:

  1. .angular-cli.json 文件中设置 outDir :
  1. Set the outDir in .angular-cli.json file:

    Angular 2项目根目录中的
  1. 类型:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆