在YML中为JPA设置休眠方言

时间:2018-09-28 00:32:36

标签: spring hibernate spring-boot jpa configuration

我试图在YML中为jpa设置休眠方言,

检查了许多主题,但未设置:

spring:
 datasource:
  hikari:
   allow-pool-suspension: true
   connection-timeout: 1000
name: testDb
jpa:
 database: h2
 generate-ddl: false
 database-platform: h2
 package-to-scan: com.x.model
  properties:
   hibernate:
    dialect: com.x.data.core.hibernate.dialect.ExtendedH2Dialect

h2:
 console:
  enabled: true
  path: /h2

该如何解决?

1 个答案:

答案 0 :(得分:3)

com.x.data.core.hibernate.dialect.ExtendedH2Dialect是什么?您必须将方言用作org.hibernate.dialect.H2Dialect

下面是示例

server:
port: 8096

spring:
  datasource:
    driverClassName: org.h2.Driver
    url: jdbc:h2:~/test
    username: sa
    password: 
    h2:
      console:
        enabled: true
  jpa:
    hibernate.ddl-auto: update
    generate-ddl: false
    show-sql: false
    properties:
      hibernate:
        dialect: org.hibernate.dialect.H2Dialect

注意: 我正在使用spring-boot-starter-data-jpa 2.0.5