Spring Boot 3 cannot load SpringPhysicalNamingStrategy
Your error
java.lang.ClassNotFoundException: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy3 more lines it can showFix it fast
Most common cause, 1 of 3A property still names the Spring Boot 2 class
Remove the line.
# delete this line from application.properties:
# spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
# or name Hibernate's class explicitly (Spring Boot 3.x, Hibernate 6):
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategyShort answer
ClassNotFoundException for org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy means your config or code still names a Spring Boot 2 class that was deprecated in 2.6 and removed in 3.0. Delete the setting, since snake_case names are already the default, or name Hibernate's class: CamelCaseToUnderscoresNamingStrategy on Boot 3.5, PhysicalNamingStrategySnakeCaseImpl on Boot 4.2.
Which cause do you have?
Search the sources and resources for the old class name and for the naming property. A hit in application.properties or application.yml is cause 1, a hit in a .java or .kt file is cause 2. No hit, but a ClassNotFoundException naming another strategy class, is cause 3.
grep -rnE "SpringPhysicalNamingStrategy|naming.physical-strategy|PhysicalNamingStrategySnakeCaseImpl|CamelCaseToUnderscoresNamingStrategy" src/Then find the line you see in this list and open its fix:
- 1A property still names the Spring Boot 2 class
application.properties or application.yml sets spring.jpa.hibernate.naming.physical-strategy to org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy - 2Your own Java class extends or creates SpringPhysicalNamingStrategy
The build stops at compile time with cannot find symbol for SpringPhysicalNamingStrategy in a class of your own - 3The replacement class does not exist in your Hibernate version
The old name is gone, but the ClassNotFoundException now names org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl, or Boot 4 prints a deprecation warning for CamelCaseToUnderscoresNamingStrategy
What does the error look like?
java.lang.ClassNotFoundException: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategyUnable to resolve name [org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy] as strategy [org.hibernate.boot.model.naming.PhysicalNamingStrategy]error: cannot find symbolsymbol: class SpringPhysicalNamingStrategy
Cause 1 of 3
A property still names the Spring Boot 2 class
You seeapplication.properties or application.yml sets spring.jpa.hibernate.naming.physical-strategy to org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
Check
The startup fails with ClassNotFoundException because the property hands Hibernate a class name that no longer exists. Spring Boot 2.6 deprecated SpringPhysicalNamingStrategy for removal in 3.0 in favour of CamelCaseToUnderscoresNamingStrategy, and the 3.0 migration guide says classes deprecated in 2.x are gone.
grep -rn "physical-strategy" src/main/resources/Fix
Remove the line. Spring Boot already configures CamelCaseToUnderscoresNamingStrategy as the physical naming strategy, so the old behaviour (camelCase to snake_case, lower-case table names) stays the same. Only set the property if you want something else.
# delete this line from application.properties:
# spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
# or name Hibernate's class explicitly (Spring Boot 3.x, Hibernate 6):
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategyVerify
The application context starts. With spring.jpa.show-sql=true in application.properties, the logged SQL still maps an OrderLine entity to the order_line table.
./mvnw spring-boot:runConfirmed by docs.spring.io
Cause 2 of 3
Your own Java class extends or creates SpringPhysicalNamingStrategy
You seeThe build stops at compile time with cannot find symbol for SpringPhysicalNamingStrategy in a class of your own
Check
A custom naming strategy written for Spring Boot 2 usually subclasses SpringPhysicalNamingStrategy or returns it from a @Bean method. Its import points at a class removed in 3.0, so javac fails before the app can start. Boot picks up any PhysicalNamingStrategy bean it finds, so the bean itself is still the right idea.
grep -rn "SpringPhysicalNamingStrategy" src/main/java src/main/kotlin 2>/dev/nullFix
Extend the Hibernate class for your Hibernate version and keep your overrides. On Spring Boot 4 with Hibernate 7 that is PhysicalNamingStrategySnakeCaseImpl; on Boot 3 with Hibernate 6 it is CamelCaseToUnderscoresNamingStrategy.
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
class NamingConfig {
@Bean
PhysicalNamingStrategySnakeCaseImpl physicalNamingStrategy() {
return new PhysicalNamingStrategySnakeCaseImpl() {
@Override
public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment env) {
return name; // keep column names as written
}
};
}
}Verify
The project compiles, and the column names in the generated SQL match your override.
./mvnw -q compileConfirmed by docs.spring.io
Cause 3 of 3
The replacement class does not exist in your Hibernate version
You seeThe old name is gone, but the ClassNotFoundException now names org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl, or Boot 4 prints a deprecation warning for CamelCaseToUnderscoresNamingStrategy
Check
The two Hibernate classes belong to different major versions. PhysicalNamingStrategySnakeCaseImpl is part of Hibernate 7 and has no page in the Hibernate 6.6 Javadoc, the line that Spring Boot 3.5 ships. In Hibernate 7, CamelCaseToUnderscoresNamingStrategy is marked deprecated for removal and only extends the new class.
./mvnw dependency:tree -Dincludes=org.hibernate.orm:hibernate-coreFix
Match the class to the hibernate-core version that the tree prints. Use CamelCaseToUnderscoresNamingStrategy with Hibernate 6.x and PhysicalNamingStrategySnakeCaseImpl with Hibernate 7.x, or drop the property and keep Boot's default.
# Spring Boot 4.x (Hibernate 7)
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategySnakeCaseImpl
# Spring Boot 3.x (Hibernate 6)
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategyVerify
Startup completes with no ClassNotFoundException and no deprecation warning about the naming strategy.
./mvnw spring-boot:run 2>&1 | grep -i "namingstrategy"Confirmed by docs.hibernate.org
How do I stop it coming back?
- Before a major Spring Boot upgrade, build once on the last minor of the old line with deprecation warnings on, and clear every warning first.
- Do not set spring.jpa.hibernate.naming.physical-strategy unless you need a non-default strategy; fewer explicit class names means fewer breaks.
- Let the Spring Boot BOM pick hibernate-core instead of pinning it, so the naming class always matches the Boot line.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Dispatch Pro.