ReactJS webapp in SpringBoot is a webapp that is running inside Spring Boot as any other Javascript library with the use of Thymeleaf.
Thymeleaf in Spring Boot requires static/index.html file, which is defined in application.properties file.
spring.thymeleaf.prefix=classpath:/static/
With this, instead of defining a static index.html, we drive spring's thymeleaf to target's static directory that maven builds while preparing reactJS integration in Spring Boot.
As you can see on pom.xml, you can create your own reactJS application instead of the current, as long as it use npm & yarn node package managers, which maven will prepare for you during the packaging.
<frontend-src-dir>${project.basedir}/reactjs</frontend-src-dir>
- java 8
- maven
- npx (if you want to create you own webapp from scratch)
To build the server, we will need to execute the following lines:
mvn clean package
To run the server, we will need only java
java -jar target/reactjs-in-springboot-0.0.1-SNAPSHOT.jar
To build the server in Docker, we will need to execute the following lines:
./local.build.and.run.sh
Beware that if you use your own reactjs in different directory than reactjs, you need to update Dockerfile with the respective directory name. Otherwise, your reactjs app won't copied on the container.
As you already know, the command to create a new reactjs app from scratch with npx is:
npx create-react-app yourreactjs
You can proceed with your development with reactJS separately at localhost:3000 by starting the reactjs with the following command:
npm start
# or
yarn start
- Please, provide your issues or feature requests at reactjs-in-springboot issues page. )