
- Spring Boot ORM 教程
- Spring Boot ORM - 主頁
- Spring Boot ORM - 概覽
- 環境設定
- Spring Boot ORM - JPA
- Spring Boot ORM 和 Spring 資料 JPA
- Spring Boot ORM - 建立專案
- application.properties
- Spring Boot ORM - 更新專案
- Spring Boot ORM - 測試 Hibernate
- Spring Boot ORM 和 EclipseLink
- Maven EclipseLink
- 更新專案 EclipseLink
- Spring Boot ORM - 測試 EclipseLink
- Spring Boot ORM 有用資源
- Spring Boot ORM - 快速指南
- Spring Boot ORM - 有用資源
- Spring Boot ORM - 討論
Spring Boot ORM - application.properties
Spring boot 讀入 application.properties 中的應用程式以及持久相關屬性。在此我們還可以配置 Hibernate 或任何其他 ORM 框架特定屬性。我們正在使用通用屬性,以便我們可以在 ORM 之間切換,而無需更改很多程式碼。預設情況下,如果在 **POM.xml** 中沒有指定其他 ORM 庫,則 spring boot 配置 Hibernate 作為 ORM 提供程式。
在 **src −> main −> resources** 目錄下建立 **application.properties**,並按如下所示更新。
application.properties
spring.application.name=springbootorm #datasource configurations spring.datasource.url=jdbc:mysql://:3306/tutorialspoint 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
以下是 application.properties 的關鍵屬性的說明。
**spring.datasource** − 資料庫特定屬性,例如連線 URL、使用者名稱、密碼、驅動類等。
**spring.jpa** − jpa 特定屬性,例如顯示 sql、允許建立表等。
廣告