Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot + Angular 2 structure

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.

like image 789
Tomas Marik Avatar asked Dec 31 '16 09:12

Tomas Marik


2 Answers

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:

enter image description here

  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 )

like image 173
Tomas Marik Avatar answered Sep 21 '22 05:09

Tomas Marik


There's an framework called JHipster. It is easily to develop, deploy Spring Boot + Angular Apps. Check out their sample and it would helpful. The link is here: https://jhipster.github.io/

Jhipster supports both AngularJS and Angular, therefore you can find the both sources

like image 23
Haifeng Zhang Avatar answered Sep 21 '22 05:09

Haifeng Zhang