未知的访问类型记录

huangapple go评论61阅读模式
英文:

Unknown access type record

问题

以下是错误消息的翻译:

2023-06-12T19:16:36.570+03:00  INFO 21364 --- [           main] com.example.weather.WeatherApplication   : 使用 Java 20.0.1 启动 WeatherApplication,进程ID为 21364 (C:\Users\Professional\IdeaProjects\weather\target\classes,由 Professional 在 C:\Users\Professional\IdeaProjects\weather 中启动)
2023-06-12T19:16:36.572+03:00  INFO 21364 --- [           main] com.example.weather.WeatherApplication   : 未设置活动配置文件,回退到默认配置: "default"
2023-06-12T19:16:37.174+03:00  INFO 21364 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : 以 DEFAULT 模式引导 Spring Data JPA 存储库。
2023-06-12T19:16:37.236+03:00  INFO 21364 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : 在 54 毫秒内完成 Spring Data 存储库扫描。找到 1 个 JPA 存储库接口。
2023-06-12T19:16:37.733+03:00  INFO 21364 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : 使用端口 8080(http)初始化 Tomcat。
2023-06-12T19:16:37.743+03:00  INFO 21364 --- [           main] o.apache.catalina.core.StandardService   : 启动服务 [Tomcat]
2023-06-12T19:16:37.743+03:00  INFO 21364 --- [           main] o.apache.catalina.core.StandardEngine    : 启动 Servlet 引擎: [Apache Tomcat/10.1.8]
2023-06-12T19:16:37.835+03:00  INFO 21364 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : 初始化 Spring 嵌入式 WebApplicationContext
2023-06-12T19:16:37.835+03:00  INFO 21364 --- [           main] w.s.c.ServletWebServerApplicationContext : 根 WebApplicationContext: 在 1207 毫秒内完成初始化
2023-06-12T19:16:37.987+03:00  INFO 21364 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : 处理持久性单元信息 [name: default]
2023-06-12T19:16:38.044+03:00  INFO 21364 --- [           main] org.hibernate.Version                    : Hibernate ORM 核心版本 6.2.2.Final
2023-06-12T19:16:38.046+03:00  INFO 21364 --- [           main] org.hibernate.cfg.Environment            : 使用字节码反射优化器
2023-06-12T19:16:38.095+03:00  INFO 21364 --- [           main] o.hibernate.annotations.common.Version   : Hibernate Commons Annotations 版本 {5.1.2.Final}
2023-06-12T19:16:38.626+03:00  INFO 21364 --- [           main] o.h.b.i.BytecodeProviderInitiator        : 字节码提供程序名称: bytebuddy
2023-06-12T19:16:38.773+03:00  INFO 21364 --- [           main] o.s.o.j.p.SpringPersistenceUnitInfo      : 未设置 LoadTimeWeaver 设置: 忽略 JPA 类转换器
2023-06-12T19:16:38.789+03:00  INFO 21364 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - 启动...
2023-06-12T19:16:38.977+03:00  INFO 21364 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - 添加连接 org.postgresql.jdbc.PgConnection@31e7afde
2023-06-12T19:16:38.978+03:00  INFO 21364 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - 启动已完成。
2023-06-12T19:16:39.014+03:00  INFO 21364 --- [           main] org.hibernate.orm.dialect                : 使用方言: org.hibernate.dialect.PostgreSQL10Dialect,版本: 10.0
2023-06-12T19:16:39.015+03:00  WARN 21364 --- [           main] org.hibernate.orm.deprecation            : PostgreSQL10Dialect 已弃用;请改用 org.hibernate.dialect.PostgreSQLDialect
2023-06-12T19:16:39.123+03:00  INFO 21364 --- [           main] o.h.b.i.BytecodeProviderInitiator        : 字节码提供程序名称: bytebuddy
2023-06-12T19:16:39.353+03:00  INFO 21364 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : 使用 JtaPlatform 实现: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-06-12T19:16:39.359+03:00  INFO 21364 --- [           main] j.LocalContainerEntityManagerFactoryBean : 初始化 JPA EntityManagerFactory 以用于持久性单元 'default'
2023-06-12T19:16:39.546+03:00  WARN 21364 --- [           main] ConfigServletWebServerApplicationContext : 在上下文初始化期间遇到异常 - 取消刷新尝试: org.springframework.beans.factory.UnsatisfiedDependencyException: 在文件 [C:\Users\Professional\IdeaProjects\weather\target\classes\com\example\weather\controller\WeatherController.class] 中定义的名称为 'weatherController' 的 bean 创建时发生 Unsatisfied dependency 表达式,通过构造函数参数 2 表达: 在 com.example.weather.repository.WeatherRepository 中定义的名称为 'weatherRepository' 的 bean 创建时发生 Unsatisfied dependency 表达式,通过 @EnableJpaRepositories 上声明的 JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: 不是受管理的类型: class com.example.weather.model.Weather
2023-06-12T19:16:39.547+03:00  INFO 21364 --- [           main

<details>
<summary>英文:</summary>

I am trying to add a Weather object to the database using jakarta and jparepository. The following error occurs: Unknown access type record. Initially, there was javax instead of jakarta, but there was an error that the object was unmanaged. I changed to jakarta and a new error appeared. When replacing JpaRepository with Crudrepository, nothing changes either.


package com.example.weather;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication
@EnableJpaRepositories(basePackages = "com.example.weather.repository")
public class WeatherApplication {
public static void main(String[] args) {
SpringApplication.run(WeatherApplication.class, args);
}
}



package com.example.weather.repository;

import com.example.weather.model.Weather;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface WeatherRepository extends JpaRepository<Weather, Long> {

}



package com.example.weather.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "weather")
public class Weather implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;

@Column(name = &quot;city&quot;)
private String city;
@Column(name = &quot;temp&quot;)
@JsonProperty(&quot;temp&quot;)
private int temp;
@Column(name = &quot;wind_speed&quot;)
@JsonProperty(&quot;wind_speed&quot;)
private double wind_speed;
@Column(name = &quot;wind_degrees&quot;)
@JsonProperty(&quot;wind_degrees&quot;)
private double wind_degrees;
@Column(name = &quot;humidity&quot;)
@JsonProperty(&quot;humidity&quot;)
private int humidity;
@Column(name = &quot;sunset&quot;)
@JsonProperty(&quot;sunset&quot;)
private int sunset;
@Column(name = &quot;min_temp&quot;)
@JsonProperty(&quot;min_temp&quot;)
private int min_temp;
@Column(name = &quot;cloud_pct&quot;)
@JsonProperty(&quot;cloud_pct&quot;)
private int cloud_pct;
@Column(name = &quot;feels_like&quot;)
@JsonProperty(&quot;feels_like&quot;)
private int feels_like;
@Column(name = &quot;sunrise&quot;)
@JsonProperty(&quot;sunrise&quot;)
private int sunrise;
@Column(name = &quot;max_temp&quot;)
@JsonProperty(&quot;max_temp&quot;)
private int max_temp;

public void Print(){
    System.out.println(String.format(&quot;id = %s\ncity = %s\ntemp = %s\nwind_speed = %s\nwind_degrees = %s\n&quot; +
            &quot;humidity = %s\nsunset = %s\nmin_temp = %s\ncloud_pct = %s\nfeels_like = %s\nsunrise = %s\nmax_temp = %s&quot;,
            id, city, temp, wind_speed, wind_degrees, humidity, sunset, min_temp, cloud_pct, feels_like, sunrise, max_temp));
}

}



package com.example.weather.controller;

import com.example.weather.jms.WeatherListener;
import com.example.weather.jms.WeatherProducer;
import com.example.weather.model.Weather;
import com.example.weather.repository.WeatherRepository;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

@RestController
@RequestMapping("/weather")
@Transactional
public class WeatherController {

private final WeatherProducer weatherProducer;
private final WeatherListener weatherListener;
private final WeatherRepository weatherRepository;

@Autowired
public WeatherController(WeatherProducer weatherProducer, WeatherListener weatherListener, WeatherRepository weatherRepository) {
    this.weatherProducer = weatherProducer;
    this.weatherListener = weatherListener;
    this.weatherRepository = weatherRepository;
}

@GetMapping(&quot;{city}&quot;)
public int getWeather(@PathVariable String city) throws Exception{
    URL url = new URL(&quot;https://api.api-ninjas.com/v1/weather?city=&quot; + city);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.addRequestProperty(&quot;X-Api-Key&quot;, &quot;aCQf5mYIfKNIhy2etdORbQ==4lC2SUpMjyg9CTpq&quot;);
    InputStream responseStream = connection.getInputStream();
    ObjectMapper mapper = new ObjectMapper();
    JsonNode root = mapper.readTree(responseStream);
    Weather weather = mapper.readValue(root.toString(), Weather.class);
    weather.setCity(city);

    //weatherProducer.sendWeather(weather);
    weatherRepository.save(weather);

    int currentTemperature = weather.getTemp();

    return currentTemperature;
}

}


Error code: 

2023-06-12T19:16:36.570+03:00 INFO 21364 --- [ main] com.example.weather.WeatherApplication : Starting WeatherApplication using Java 20.0.1 with PID 21364 (C:\Users\Professional\IdeaProjects\weather\target\classes started by Professional in C:\Users\Professional\IdeaProjects\weather)
2023-06-12T19:16:36.572+03:00 INFO 21364 --- [ main] com.example.weather.WeatherApplication : No active profile set, falling back to 1 default profile: "default"
2023-06-12T19:16:37.174+03:00 INFO 21364 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-06-12T19:16:37.236+03:00 INFO 21364 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 54 ms. Found 1 JPA repository interfaces.
2023-06-12T19:16:37.733+03:00 INFO 21364 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-06-12T19:16:37.743+03:00 INFO 21364 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-06-12T19:16:37.743+03:00 INFO 21364 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.8]
2023-06-12T19:16:37.835+03:00 INFO 21364 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-06-12T19:16:37.835+03:00 INFO 21364 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1207 ms
2023-06-12T19:16:37.987+03:00 INFO 21364 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-06-12T19:16:38.044+03:00 INFO 21364 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.2.2.Final
2023-06-12T19:16:38.046+03:00 INFO 21364 --- [ main] org.hibernate.cfg.Environment : HHH000406: Using bytecode reflection optimizer
2023-06-12T19:16:38.095+03:00 INFO 21364 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-06-12T19:16:38.626+03:00 INFO 21364 --- [ main] o.h.b.i.BytecodeProviderInitiator : HHH000021: Bytecode provider name : bytebuddy
2023-06-12T19:16:38.773+03:00 INFO 21364 --- [ main] o.s.o.j.p.SpringPersistenceUnitInfo : No LoadTimeWeaver setup: ignoring JPA class transformer
2023-06-12T19:16:38.789+03:00 INFO 21364 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-06-12T19:16:38.977+03:00 INFO 21364 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@31e7afde
2023-06-12T19:16:38.978+03:00 INFO 21364 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-06-12T19:16:39.014+03:00 INFO 21364 --- [ main] org.hibernate.orm.dialect : HHH035001: Using dialect: org.hibernate.dialect.PostgreSQL10Dialect, version: 10.0
2023-06-12T19:16:39.015+03:00 WARN 21364 --- [ main] org.hibernate.orm.deprecation : HHH90000026: PostgreSQL10Dialect has been deprecated; use org.hibernate.dialect.PostgreSQLDialect instead
2023-06-12T19:16:39.123+03:00 INFO 21364 --- [ main] o.h.b.i.BytecodeProviderInitiator : HHH000021: Bytecode provider name : bytebuddy
2023-06-12T19:16:39.353+03:00 INFO 21364 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-06-12T19:16:39.359+03:00 INFO 21364 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-06-12T19:16:39.546+03:00 WARN 21364 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'weatherController' defined in file [C:\Users\Professional\IdeaProjects\weather\target\classes\com\example\weather\controller\WeatherController.class]: Unsatisfied dependency expressed through constructor parameter 2: Error creating bean with name 'weatherRepository' defined in com.example.weather.repository.WeatherRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.weather.model.Weather
2023-06-12T19:16:39.547+03:00 INFO 21364 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-06-12T19:16:39.548+03:00 INFO 21364 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-06-12T19:16:39.604+03:00 INFO 21364 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2023-06-12T19:16:39.606+03:00 INFO 21364 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2023-06-12T19:16:39.619+03:00 INFO 21364 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-06-12T19:16:39.636+03:00 ERROR 21364 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'weatherController' defined in file [C:\Users\Professional\IdeaProjects\weather\target\classes\com\example\weather\controller\WeatherController.class]: Unsatisfied dependency expressed through constructor parameter 2: Error creating bean with name 'weatherRepository' defined in com.example.weather.repository.WeatherRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.weather.model.Weather
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1189) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:941) ~[spring-context-6.0.9.jar:6.0.9]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.9.jar:6.0.9]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.0.jar:3.1.0]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) ~[spring-boot-3.1.0.jar:3.1.0]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) ~[spring-boot-3.1.0.jar:3.1.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-3.1.0.jar:3.1.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[spring-boot-3.1.0.jar:3.1.0]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) ~[spring-boot-3.1.0.jar:3.1.0]
at com.example.weather.WeatherApplication.main(WeatherApplication.java:10) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'weatherRepository' defined in com.example.weather.repository.WeatherRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.weather.model.Weather
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1417) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:888) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-6.0.9.jar:6.0.9]
... 19 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.weather.model.Weather
at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:192) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:465) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:97) ~[hibernate-core-6.2.2.Final.jar:6.2.2.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:80) ~[spring-data-jpa-3.1.0.jar:3.1.0]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:69) ~[spring-data-jpa-3.1.0.jar:3.1.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:246) ~[spring-data-jpa-3.1.0.jar:3.1.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:211) ~[spring-data-jpa-3.1.0.jar:3.1.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:194) ~[spring-data-jpa-3.1.0.jar:3.1.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-3.1.0.jar:3.1.0]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:317) ~[spring-data-commons-3.1.0.jar:3.1.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279) ~[spring-data-commons-3.1.0.jar:3.1.0]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:245) ~[spring-data-commons-3.1.0.jar:3.1.0]
at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-3.1.0.jar:3.1.0]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:285) ~[spring-data-commons-3.1.0.jar:3.1.0]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) ~[spring-data-jpa-3.1.0.jar:3.1.0]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816) ~[spring-beans-6.0.9.jar:6.0.9]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.9.jar:6.0.9]
... 30 common frames omitted


</details>


# 答案1
**得分**: 1

我遇到了相同的问题,是由于冲突的 Hibernate Core 版本引起的。在我移除了旧版本后,保留了 6.2.6.Final 版本,成功启动。

<details>
<summary>英文:</summary>

I faced the same issue caused have conflicting hibernate core version, after I remove the older one, and keep the 6.2.6.Final one. start successfully.

</details>



# 答案2
**得分**: 0

我在尝试使用 hibernate-search-orm-mapper 时遇到了相同的问题。
问题在于这个特定的依赖项没有由 springboot-starter-data-jpa 管理。因此,data-jpa 尝试使用 hibernate 6.2.2 jar,而 search-orm-mapper 尝试使用 5.1.2。

我不得不查找两者都使用相同的 hibernate-core jar 版本的情况。对于我的情况来说,这个幸运的巧合是 spring 版本 2.6.6 和 search-orm 版本 6.1.3-Final,现在都使用 hibernate-core 5.6.7。

类似的方法,你需要找到你的情况。使用 mvn dependency:tree 命令查找具有不同版本的重复依赖项,你将在那里找到罪魁祸首,然后在 Maven 中央仓库中检查这两个依赖项,看看哪个版本的编译依赖项匹配。

<details>
<summary>英文:</summary>

I faced the same problem when I tried to use hibernate-search-orm-mapper.
The problem is this particular dependency is not managed by springboot-starter-data-jpa. So data-jpa tried to use hibernate 6.2.2 jar while search-orm-mapper tried to use 5.1.2.

I had to check for which version both use same hibernate-core jar.. that sweet co-incidence for my case is spring version 2.6.6 and search-orm version 6.1.3-Final now both use hibernate-core 5.6.7

Similar way you have to find for your case.. use mvn dependency:tree to find duplicate dependencies with different versions, you will find your culprit there then check in maven central for both dependencies and see for which version compile dependencies matches..

</details>



# 答案3
**得分**: 0

我尝试了以下内容,似乎可以工作。请注意,我正在使用 Spring Boot 3.1.3,参考链接:https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#other-integrations-orm6

```xml
<dependency>
    <groupId>org.hibernate.orm</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>6.2.7.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate.search</groupId>
    <artifactId>hibernate-search-mapper-orm-orm6</artifactId>
    <version>6.2.1.Final</version>
</dependency>
<dependency>
    <groupId>org.hibernate.search</groupId>
    <artifactId>hibernate-search-backend-lucene</artifactId>
    <version>6.2.1.Final</version>
</dependency>
英文:

I tried the following and it seems to work. Please note that I am using Spring Boot 3.1.3, reference: https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#other-integrations-orm6

&lt;dependency&gt;
    &lt;groupId&gt;org.hibernate.orm&lt;/groupId&gt;
    &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
    &lt;version&gt;6.2.7.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.hibernate.search&lt;/groupId&gt;
    &lt;artifactId&gt;hibernate-search-mapper-orm-orm6&lt;/artifactId&gt;
    &lt;version&gt;6.2.1.Final&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.hibernate.search&lt;/groupId&gt;
    &lt;artifactId&gt;hibernate-search-backend-lucene&lt;/artifactId&gt;
    &lt;version&gt;6.2.1.Final&lt;/version&gt;
&lt;/dependency&gt;

huangapple
  • 本文由 发表于 2023年6月12日 23:20:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76458077.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定