English 中文(简体)
Application.properties
  • 时间:2024-09-17

Spring Boot ORM - Apppcation.properties


Previous Page Next Page  

Spring boot reads apppcation as well as persistence related properties from apppcation.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 pbrary is specified in POM.xml.

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

apppcation.properties


#datasource configurations
spring.datasource.url=jdbc:mysql://localhost:3306/tutorialspoint?useSSL=false&allowPubpcKeyRetrieval=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 apppcation.properties.

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

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

Advertisements