joshua.kim
joshua.kim

Reputation: 373

How to install React js with Spring framework?

I can't figure out how to install React.js for Spring framework.

A website said to first install NPM. Yes, I did that.

But how can I use React.js in Spring MVC?

  1. mac and windows need to install NPM?
  2. just use use CDN -> this case occur error
  3. how to searching basic course
  4. only use spring boot?
  5. could you give a Web site address for how to install Spring Frameworks with React.js
  6. could you give to me tips for how to install React.js for Spring Frameworks?

I'm a beginning developer.

Upvotes: 1

Views: 4944

Answers (2)

rieckpil
rieckpil

Reputation: 12051

Spring MVC and ReactJS follow some different concepts of designing your webapplication. With Spring MVC your create most of the time server side rendered webapps with JSPs or you use a template engine like Thymeleaf.

With ReactJS you are building a Singe Page Application (SPA) which can be accessed with a SINGLE HTML file, often index.html and your JavaScript is doing the rendering. With Spring MVC you provide several .html files and use Spring to route the different routes to your different .html files and render them on the server side.

The only thing I can guess is to serve your finally built ReactJS which consists only of one .html and several .js and other assets with a Spring MVC application which acts like a simple Webserver.

Furthermore you can use Spring MVC to provide RESTful interfaces for your React application.

Upvotes: 0

Brad
Brad

Reputation: 2320

The best answer I can give you is to walk through this tutorial, step by step.

https://spring.io/blog/2015/09/01/react-js-and-spring-data-rest-part-1-basic-features

To answer your first question, no, you do not need to use node.js tools to use React with Spring MVC. The tutorial above says:

This tutorial won’t go into extensive detail on how it uses require.js to load JavaScript modules. But thanks to the frontend-maven-plugin, you don’t have to install any of the node.js tools to build and run the code.

Upvotes: 1

Related Questions