Error creating bean with name 'entityManagerFactory' : org/hibernate/dialect/PostgreSQL82Dialect

3.2k Views Asked by At

I'm migrating the spring boot parent version from 2.5.12 to 3.0.6 and I faced many issues that I could fix but I struggle with this one :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: org/hibernate/dialect/PostgreSQL82Dialect


Caused by: java.lang.NoClassDefFoundError: org/hibernate/dialect/PostgreSQL82Dialect
    at com.vladmihalcea.hibernate.type.HibernateTypesContributor.contribute(HibernateTypesContributor.java:34)
    at org.hibernate.boot.internal.MetadataBuilderImpl.applyTypes(MetadataBuilderImpl.java:296)

my pom.xml (only dependencies affected):

<!-- versions -->
    <hibernate-core.version>6.2.5.Final</hibernate-core.version>
    <hibernate-types.version>2.16.3</hibernate-types.version>
    <postgresql.version>42.5.4</postgresql.version>
    <spring.boot.version>3.0.6</spring.boot.version>
    
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
      <version>${spring.boot.version}</version>
    </dependency>
    <dependency>
      <groupId>com.vladmihalcea</groupId>
      <artifactId>hibernate-types-52</artifactId>
      <version>${hibernate-types.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>${hibernate-core.version}</version>
      <scope>compile</scope>
    </dependency>

application properties :


  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect

java version : 17

1

There are 1 best solutions below

0
On

Take note that you are still using hibernate-types52 which refers to previous major hibernate 5+. You should refer to the latest hibernate-types60 dependency to fully migrate to hibernate 6+. As of time, you can use the following:

<dependency>
        <groupId>com.vladmihalcea</groupId>
        <artifactId>hibernate-types-60</artifactId>
        <version>2.21.1</version>
</dependency>