This project is an example to generate a fake data based on instancio in Spring boot application with JPA.
The application example used is the popular Spring pet clinic spring pet clinic
- checkout spring pet clinic application from fork repos
git clone https://github.com/anasoid/spring-petclinic.git
- Install spring petclinic in local maven repo
cd spring-petclinic
./mvnw package
./mvnw install:install-file -Dfile=./target/spring-petclinic-3.4.0-SNAPSHOT.jar.original -DgroupId=org.springframework.samples -DartifactId=spring-petclinic -Dversion=3.4.0-SNAPSHOT -Dpackaging=jar
- Checkout this repo in different folder
git clone https://github.com/anasoid/instancio-petclinic-jpa-example.git
- Run sring boot petclinic app
./gradlew bootRun
- Visit url http://localhost:8080
- There is two spring boot application present in this repos:
- InstancioPetClinicJpaExampleApplication: Console application that generate data in database, should be used with mysql or other server database to be visible.
- PetClinicWithDataApplication: Star the original spring pet clinic and generated data in h2 in memory database.
The code to generate petclinic data is presents in package "org.anasoid.instancio.petclinic.jpa.example.petclinic" other class form "org.anasoid.instancio.petclinic.jpa.example.core" can be resused in different applications.
The config file by entity is present in entity-config.yaml
Entity | Remarque |
---|---|
Vet | generate 10 vets, with one or two specialities |
Owner | generate minimum 100 owners, with one or two pets |
Specialty | generate 5 specialities based on csv file specialty.csv |
Pet | generate one or two pets by owners |
Pettype | generate 5 pettype based on csv file [pettype.csv](src/main/ resources/data/pettype.csv) |
Visit | generate zero to fives visits by pets |