[简]SpringDataJPA+PostgreSQL的配置

The following properties are applied to the Spring Data JPA configuration of using Postgres as its DBSM.
Two configuration files will be modified to achieve the goal.

  1. pom.xml
    We need to add the PostgreSQL's dependency to your dependency list.
<dependencies>
    ...
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    ...
</dependencies>
  1. application.properties
    This file is usually located in the main/resources/ folder.
    Figure 1. Location of the application.properties file
# Postgres
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/test
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.show-sql: true

# Connection pool
spring.datasource.hikari.connectionTimeout=20000
spring.datasource.hikari.maximumPoolSize=5
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容