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

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

问题描述

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

  1. Spring Boot App 的结构由

    1. Angular 2 项目根目录中输入:

      ng 构建

    <小时>

    (!请注意,这适用于 Angular CLI 工具中生成的 Angular 2 项目,对于不是由 Angular CLI 工具创建的 Angular 2 项目,outDir在 tsconfig.json 文件中编辑 )

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

    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)

    In Angular 1 you can put your index.html into public folder.

    In Angular 2 the index.html is generated in src folder and I would like to keep that structure.

    My question is what should I do to make index.html visible for Spring Boot and keep the structure generated by Angular CLI.

    Thanks for any answer.

    解决方案

    Solution is to relocate build output of an Angular 2 project into Spring Boot /static or /public folder.

    2 Steps:

    1. Set the outDir in .angular-cli.json file:

    1. in the Angular 2 project root directory type:

      ng build
      


    (! 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天全站免登陆