Spring Boot app with REST API demo, using the following frameworks:
- Java 8
- SpringBoot
- JPA & Hibernate
- H2 & MySQL
- Maven
spring init -n=demo -d=web,jpa,mysql,devtools --package-name=com.fmcat demo
the project is generated in ./demo folder
Go to http://start.spring.io
- set package to: com.fmcat
- set name to: demo
- add dependencies: web jpa mysql devtools
- generate project (...the project is downloaded)
- open terminal and go to the generated folder (unzip downloaded file)
the project is doenloaded as zip file. Unzip and go into the folder
Not required if using H2.
For other SQL engines create a new database using your IDE of choice, with :
name: mydatabase
user: *****
pwd: ******
Edit src/main/resources/application.properties Add database details and hibernate preferences
spring.datasource.url=jdbc:mysql://localhost:3306/mydatabase?useSSL=false
spring.datasource.username=*******
spring.datasource.password=*******
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto = update
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type=TRACE
Options: