https://github.com/nnishad/reactive-springboot-with-reactjs-app
Single jar-based server for both frontend and backend. This project has springboot for backend with Reactjs application embeded as static resource to it.
https://github.com/nnishad/reactive-springboot-with-reactjs-app
embeded-reactjs hacktoberfest hacktoberfest-accepted hacktoberfest2022 jar reactjs spring springboot
Last synced: about 2 months ago
JSON representation
Single jar-based server for both frontend and backend. This project has springboot for backend with Reactjs application embeded as static resource to it.
- Host: GitHub
- URL: https://github.com/nnishad/reactive-springboot-with-reactjs-app
- Owner: nnishad
- Created: 2022-10-07T13:00:11.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-08T17:50:16.000Z (over 3 years ago)
- Last Synced: 2025-10-08T20:23:18.774Z (9 months ago)
- Topics: embeded-reactjs, hacktoberfest, hacktoberfest-accepted, hacktoberfest2022, jar, reactjs, spring, springboot
- Language: JavaScript
- Homepage:
- Size: 89.8 KB
- Stars: 1
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SpringBoot Application bundled with ReactJs in single jar
Looking for creating a single jar-based server for both frontend and backend? This project will help you out.
## How to use during development?
We need to run both the application serprately and continue your developement.
These command can be used to run these application while development.
Root directory: ./gradlew bootRun
Frontend directory inside root: npm start
## How to build for production deployment?
Once development completed and ready for deployment, update your build.gradle file to build react app as well during this.
plugins {
id 'org.siouan.frontend-jdk11' version '6.0.0'
}
frontend {
nodeVersion = '16.1.0'
packageJsonDirectory= file("${projectDir}/frontend")
nodeInstallDirectory = file("${projectDir}/frontend/node")
assembleScript = 'run build'
}
*Above task will do the react app build for you
Now we need to copy this build to our spring application build folder
task copyReactApp(type: Copy) {
from "${projectDir}/frontend/build"
into "${projectDir}/build/resources/main/public/."
}
bootJar.dependsOn(copyReactApp)
And you are done with gradle changes to be done. Next gradle build will give you jar file with react application in it.
## How this work?
Modified build.gradle helps to execute node/npm command while building springboot application.
'org.siouan.frontend-jdk11' plugin helps to manage node related enviroment and scripts and excute them.
We ne to provid it the location where my react-app is located and node-version required and it downloads that on the go while building the spring application which actually helps to create a single jar with react production build static file to be served.