admin管理员组文章数量:1389853
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:
I have the /app
folder, and the .js
are piled 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
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:
I have the /app
folder, and the .js
are piled 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
Share Improve this question edited Nov 24, 2016 at 3:11 luboskrnac 24.6k10 gold badges86 silver badges93 bronze badges asked Jul 15, 2016 at 1:32 Felipe S.Felipe S. 1,7332 gold badges17 silver badges23 bronze badges 10- 1 My understanding was that the whole Angular 2 app should go under src/main/resources/static or similar. Does your current approach actually work? – ben3000 Commented Jul 15, 2016 at 2:39
-
The way I did, it works if I copy the
node_modules
tostatic
, but thebootRun
gets really slow and doesn't refresh the static content if it changes. I wanted to avoid putting the whole Angular 2 app so it doesn't publish unnecessary resources, but maybe that's the way I should it as you suggested.. – Felipe S. Commented Jul 15, 2016 at 2:52 - I'm very interested in responses to your question, as I've been heading down this path too, but not yet fully implemented it. – ben3000 Commented Jul 15, 2016 at 2:53
- Are you using hot swapping for your development code? – ben3000 Commented Jul 15, 2016 at 2:56
- 1 Consider separating the client code into a directory called "client". All client side goes into that directory. It is on the same level as "src". Then use your js build tool of choice to place a dist version within the src/main/resources/static – code Commented Jul 15, 2016 at 5:14
3 Answers
Reset to default 21) 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
Try really cool project builder Jhipster ;)
I shared on github a project that integrates Angular 2 with springboot. you can check here Angular 2 with spring boot
本文标签: javascriptHow to setup structure with SpringBoot and Angular2Stack Overflow
版权声明:本文标题:javascript - How to setup structure with SpringBoot and Angular2? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744661496a2618272.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论