Spring PostgreSQL Support: Difference between revisions
Jump to navigation
Jump to search
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
=External= | |||
* https://dzone.com/articles/configuring-spring-boot-for-postgresql | |||
=Internal= | =Internal= | ||
Line 15: | Line 18: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=<span id='Configuration'></span>Spring Configuration= | |||
Add in [[application.properties]] or equivalent: | |||
<syntaxhighlight lang='text'> | |||
#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres | |||
#spring.datasource.username=playground | |||
#spring.datasource.password=playground123 | |||
#spring.datasource.platform=postgres | |||
spring.datasource.initialization-mode=always | |||
spring.jpa.hibernate.ddl-auto=none | |||
spring.jpa.show-sql=true | |||
</syntaxhighlight> | |||
= | If using [[Spring_Boot_Concepts#Spring_Boot_Database_Initialization|Spring Boot Database Initialization]] and Postgres-specific DDL and DML, create schema-postgres.sql, data-postgres.sql files and configure the "plaform" as: | ||
<syntaxhighlight lang='text'> | |||
spring.datasource.platform=postgres | |||
</syntaxhighlight> | |||
More details available here: {{Internal|Spring_Boot_Concepts#Spring_Boot_Database_Initialization|Spring Boot Database Initialization}} |
Latest revision as of 06:16, 19 October 2018
External
Internal
Overview
Dependencies
dependencies {
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
runtimeOnly('org.postgresql:postgresql')
}
Spring Configuration
Add in application.properties or equivalent:
#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
#spring.datasource.username=playground
#spring.datasource.password=playground123
#spring.datasource.platform=postgres
spring.datasource.initialization-mode=always
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql=true
If using Spring Boot Database Initialization and Postgres-specific DDL and DML, create schema-postgres.sql, data-postgres.sql files and configure the "plaform" as:
spring.datasource.platform=postgres
More details available here: