Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Springboot3 with Hibernate6 error with class not found SpringPhysicalNamingStrategy

springboot 3.24 hibernete 6.44 jdk 21

error with: Suppressed: java.lang.ClassNotFoundException: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy

Searched on internet that SpringPhysicalNamingStrategy was deprecated, using CamelCaseToUnderscoresNamingStrategy instead. but I still failed after I updated the settings ,

spring:
  jpa:
    hibernate:
      naming:
        physical-strategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
        #physical-strategy: org.springframework.boot.orm.jpa.hibernate.CamelCaseToUnderscoresNamingStrategy
        #physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
        #physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
        #implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy

I tried to generate a totally new project by using spring initializr, copy only database related codes in it, and it also failed.

like image 895
iyaya lc Avatar asked Oct 26 '25 08:10

iyaya lc


1 Answers

finally fixed, the correct config was:

properties.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
properties.put("hibernate.ddl-auto", "update");
properties.put("hibernate.id.new_generator_mappings", "false");
properties.put("hibernate.physical_naming_strategy", "org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy");

first, using MySQLDialect instead of MySQL5InnoDBDialect, it's deleted. second,using "org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy" not springframework jar.

like image 136
iyaya lc Avatar answered Oct 28 '25 20:10

iyaya lc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!