Reputation: 403
I just made the move from Angular 1 to 2, and now I am going to create a spring mvc maven webapp with angular2 for the front-end side of it.
But everywhere on the internet I see people using node.js for the necessary libraries & plugins. Is there a way I can just use maven dependencies for this?
App structure:
_ main
_ java
_ resources
_ webapp
_ components
_ app.component.ts
_ img
_ WEB-INF
_ index.html
_ main.ts
main.ts
//getting an error on the bootstrap import
//because the angular2 folders aren't there because there is no node
import {bootstrap} from 'angular2/platform/browser'
import {AppComponent} from './components/app.component.ts'
bootstrap(AppComponent);
Upvotes: 2
Views: 3487
Reputation: 3604
I personaly use Angular2
with a backend in Java
, the whole packaged in a .war file.
Backend libraries are managed with Maven
, and front end with NPM
. My project structure is like this :
_ backend
_ src
_ main
_ java
_resources
_ frontend
<angular-cli project>
_ package.json ...
Note that NPM
manage all my front dependencies, for now, I don't bundle anything because my application run in debug for now.
I have a deployement script wich copy the bundled version of my frontend in resources/static (or webapp) folder of the backend.
If you want some help to manage your webapp folder for Angular2
, you can try AngularCLI. The project is at a very early stage, but you can do some interesting thing with it, and it will help you to create the boilerplate, it will download for you all the dependencies.
Upvotes: 3