Felipe S.
Felipe S.

Reputation: 1723

How to setup structure with SpringBoot and Angular2?

I'm trying to use Angular2 with Springboot, but I can't set them together.

I first started a springboot project, and then tried to follow the Angular 2 Tour of Heroes by johnpapa and run npm install.

The structure looks like below:

Structure

I have the /app folder, and the .js are compiled to resources/static/app/js.

Problems:

1) The folder resources/static/node_modules/ has lots of files. So when running bootRun, it gets really slow and sometimes can't even refresh the files. I believe I shouldn't put the node_modules there, but not sure..

2) npm install puts the files in ./node_modules so currently I copied them to static folder. Should I just build the node_modules to static?

3) My structure looks hacky.. what is the best way to do it ?

How to set this structure? Also, please let me know if I should start using grunt/gulp or some other tool to make this easier.

Ps.: In case anyone is interested in the johnpapa's guide: johnpapa's angular2 guide

Upvotes: 11

Views: 3539

Answers (3)

Maksym
Maksym

Reputation: 4574

Try really cool project builder Jhipster ;)

Upvotes: 1

Mauricio Lassakoski
Mauricio Lassakoski

Reputation: 11

I shared on github a project that integrates Angular 2 with springboot. you can check here Angular 2 with spring boot

Upvotes: -1

luboskrnac
luboskrnac

Reputation: 24561

1) Remove node_modules from static folder. Your build process should bundle all the necessary modules. node_modules is used only during build.

2) Do not copy node_modules into static folder

3) Remove sources from static folder. That one is meant only for generated bundle + some static PROD files like index.html

Upvotes: 2

Related Questions