SpringBoot 1.5.9.RELEASE启动报错:JpaVendorAdapter实例化失败
org.hibernate.OptimisticLockException in Spring Boot 1.5.9.RELEASE Hey there, let's break down why your Spring Boot + JPA app is throwing that annoying NoClassDefFoundError and how to fix it. I’ve looked over your config and pom, and here’s what’s going wrong:
Your Current Setup
application.properties Configuration
server.port: 8083 spring.datasource.url=jdbc:mysql://localhost:3306/restdb spring.datasource.username=ricky spring.datasource.password=ricky spring.datasource.driver-class-name=com.mysql.jdbc.Driver
The Root Cause in Your pom.xml
Your pom includes explicit Hibernate dependencies that are causing version conflicts:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> </dependency>
The problem here is that Spring Boot’s spring-boot-starter-parent already manages all compatible dependency versions automatically. The spring-boot-starter-data-jpa starter already includes hibernate-core and hibernate-entitymanager, while spring-boot-starter-web covers hibernate-validator. When you add these dependencies manually without specifying versions, Maven might pull in versions that don’t match what Spring Boot expects, leading to missing classes like org.hibernate.OptimisticLockException.
The Solution
Remove those three explicit Hibernate dependencies from your pom.xml. Here’s the cleaned-up, working version:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.chatrabazar</groupId> <artifactId>SpringBootRest</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>SpringBootRest</name> <description>Demo Project for Spring boot and Spring Rest</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> <relativePath /> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
Then follow these steps to ensure everything works smoothly:
- Clean and rebuild your project with Maven: run
mvn clean installto wipe old dependencies and pull in the correct, Spring Boot-managed versions - Restart your Spring Boot application
This should resolve the NoClassDefFoundError because you’re now relying on Spring Boot’s curated dependency versions that are guaranteed to work together.
内容的提问来源于stack exchange,提问作者Gautam Tyagi

