Задать вопрос
@Mark890

Не запускается Spring — приложение?

Здравствуйте, помогите пожалуйста.
При запуске приложения дает такую ошибку:
***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:296)

The following method did not exist:

    'void org.hibernate.annotations.common.reflection.ReflectionManager.reset()'

The calling method's class, org.hibernate.internal.SessionFactoryImpl, is available from the following locations:

    jar:file:/C:/Users/user/.m2/repository/org/hibernate/orm/hibernate-core/6.2.7.Final/hibernate-core-6.2.7.Final.jar!/org/hibernate/internal/SessionFactoryImpl.class
    jar:file:/C:/Users/user/.m2/repository/org/hibernate/hibernate-core/4.3.11.Final/hibernate-core-4.3.11.Final.jar!/org/hibernate/internal/SessionFactoryImpl.class

The calling method's class was loaded from the following location:

    file:/C:/Users/user/.m2/repository/org/hibernate/orm/hibernate-core/6.2.7.Final/hibernate-core-6.2.7.Final.jar

The called method's class, org.hibernate.annotations.common.reflection.ReflectionManager, is available from the following locations:

    jar:file:/C:/Users/user/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar!/org/hibernate/annotations/common/reflection/ReflectionManager.class

The called method's class hierarchy was loaded from the following locations:

    org.hibernate.annotations.common.reflection.ReflectionManager: file:/C:/Users/user/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.5.Final/hibernate-commons-annotations-4.0.5.Final.jar


Action:

Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.internal.SessionFactoryImpl and org.hibernate.annotations.common.reflection.ReflectionManager


Мой Pom.xml:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.1.3</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>blog</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>blog</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>20</java.version>
	</properties>


	<dependencies>


		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
			<version>8.0.33</version>
		</dependency>



		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>

		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>4.3.11.Final</version>
		</dependency>





		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<scope>runtime</scope>
			<optional>true</optional>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
			<exclusions>
				<exclusion>
					<groupId>org.junit.vintage</groupId>
					<artifactId>junit-vintage-engine</artifactId>
				</exclusion>
			</exclusions>
		</dependency>






	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

</project>


Мой application.properties:

spring.jpa.show-sql=true
spring.h2.console.enabled=true
spring.jpa.defer-datasource-initialization=true
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver


spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/spring_web_blog
spring.datasource.username=root
spring.datasource.password=
spring.jpa.generate-ddl=true

Спасибо за помощь.
  • Вопрос задан
  • 724 просмотра
Подписаться 1 Средний 1 комментарий
Пригласить эксперта
Ответы на вопрос 1
xez
@xez Куратор тега Java
TL Junior Roo
Вы используете spring-boot.
Не нужно указывать версии hibernate. Совместимая версия уже указана в пэрент-поме спрингбута.

hibernate-core версии 4.3.11.Final вышел в далеком 2015м во времена восьмой джавы.
java 20 вышла в этом году.
Вряд-ли они вместе заработают.

Удалите эту зависимость:
<dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>4.3.11.Final</version>
    </dependency>
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы