Git Product home page Git Product logo

nnishad / reactive-springboot-with-reactjs-app Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 2.0 92 KB

Single jar-based server for both frontend and backend. This project has springboot for backend with Reactjs application embeded as static resource to it.

HTML 22.26% CSS 12.03% JavaScript 47.05% Java 18.67%
jar reactjs spring springboot embeded-reactjs hacktoberfest hacktoberfest-accepted hacktoberfest2022

reactive-springboot-with-reactjs-app's Introduction

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.

reactive-springboot-with-reactjs-app's People

Contributors

nnishad avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.