This application demonstrates the Spring boot JPA one-to-many unidirectional mapping. We can take the example of Post and Comments to demonstrate one to many mapping. We will use JSP as our view template engine.
Java - 1.8.x
Maven - 3.1.1
MySQL - 5.7.12
1. Clone the application
git clone https://gitlab.com/scbushan05/spring-jpa-one-to-many.git2. Create Mysql database
create database ecom3. Change mysql username and password as per your installation
open src/main/resources/application.properties
change spring.datasource.username and spring.datasource.password as per your mysql installation
4. Build and run the app using maven
mvn packageA new JAR file will be generated at project/target/springjpa-0.0.1-SNAPSHOT.jar
5. Run the app
java -jar springjpa-0.0.1-SNAPSHOT.jarThe app will start running at http://localhost:8080/springjpa/v1.
The app provides the following features -
1. Create post
2. Create comments to posts
You can find more examples on my blog as well as on my youtube channel -
https://bushansirgur.in
https://youtube.com/b2tech