简体   繁体   中英

Can we use angular2 universal with server side JAVA

I have an web project which is using angular 2 on front end and java spring 4 on server side. I am somewhat new to angular 2. I wanted to use angular universal for prerendering. How can i able to achieve it?

is there any tutorial which explains it with Java on server side?

Is there any other library that will help me out?

Fortunately their's a library ( Angularj-Universal ) or a solution for rendering Angular4 applications on the server side (Spring Boot or Java EE) and sending them to the browser as 'already-bootstraped' application.

Angularj-Universal library is a server side rendering for Spring Boot and Angular4 based on the J2V8 library, also you can implement your own render implementation.

On the home page of this project you will find a useful guides step-by-step on how to create angular application from scratch and integrate it with Spring Boot using @angular/cli

Angular 2 Universal works with nodejs/asp.net only.

You could use java server for rest api and separate nodejs server for pre-rendering or play with v8 jni bindings.

https://github.com/angular/universal#getting-started

Unfortunately there are not much support available for now.

Angular Universal was originally built to work with a node.js back-end. There are adapters for most popular node.js server-side frameworks such as Express or Hapi.js. In addition to node.js, however, Angular Universal has ASP.NET Core support. In the near future we hope to add support for Java , PHP and Python. - Related page -

You can follow this issues ( spring boot support & java backend ) on github.
Additionally, check out this libraries;

Not sure if you are looking for this but here is something that might help you

Since you want to deploy your angular app within spring-boot app follow these steps

  1. Create a public folder under resources in your spring-boot project

  2. ng-build --prod, type this command on you angular project which will create a dist folder under your angular project directory

  3. copy files from you dist folder and place it in public folder under resources of your spring-boot project.

This will help you run your angular-app under spring-boot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM