Spring Boot ORM - Application.properties



Spring boot reads application as well as persistence related properties from application.properties. Here we can configure the hibernate or any other ORM framework specific properties as well. We're using generic properties so that we can switch between ORM without changing much code. By default, spring boot configure hibernate as ORM provider if no other ORM library is specified in POM.xml.

Create application.properties under src −> main −> resources directory and update as shown below.

application.properties

#datasource configurations
spring.datasource.url=jdbc:mysql://localhost:3306/tutorialspoint?useSSL=false&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=root@123
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# show SQL
spring.jpa.show-sql: true
# DDL generation
spring.jpa.generate-ddl=true

Following is the description of key attributes of application.properties.

  • spring.datasource − Database specific attributes like connection url, username, password, driver class etc.

  • spring.jpa − jpa specific attributes like to show sql, to allow create tables etc.

Advertisements