gpt4 book ai didi

spring-java-config - spring data elasticsearch 初始化方法调用失败;嵌套异常是 java.lang.AbstractMethodError

转载 作者:行者123 更新时间:2023-12-03 23:41:14 25 4
gpt4 key购买 nike

我对 Spring Data Elasticsearch 有疑问。我这样配置 elasticsearch:

@Configuration
@EnableJpaRepositories(basePackages = {"org.project.repositories"})
@EnableElasticsearchRepositories(basePackages = "org.project.repositorieselastic")
@EnableTransactionManagement
public class PersistenceContext {
@Bean
public ElasticsearchOperations elasticsearchTemplate() {
return new ElasticsearchTemplate(client());
}

@Bean
public Client client(){

Settings settings = ImmutableSettings.settingsBuilder()
// Setting "transport.type" enables this module:
.put("cluster.name", "elasticsearch")
.put("client.transport.ignore_cluster_name", false)
.build();


TransportClient client= new TransportClient(settings);
TransportAddress address = new InetSocketTransportAddress("127.0.0.1", 9300);
client.addTransportAddress(address);
return client;
}

我的仓库看起来像。

@Repository()
public interface UserFavoriteElasticRepo extends ElasticsearchRepository<UserFavorite, Long> {

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.project.repositorieselastic.UserFavoriteElasticRepo org.project.services.elastic.FavoriteIndexerService.elasticRepo; nested exception
is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userFavoriteElasticRepo': Invocation of init method failed; nested exception is java.lang.AbstractMethodError

看起来好像没有生成实现。但我不知道去哪里调查。我尝试使用一个包并使用这个 - https://github.com/izeye/spring-boot-throwaway-branches/commit/874ccba09189d6ef897bc430c43b6e3705404399但没有成功。

最佳答案

我解决了在 pom 文件中添加这个问题

<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.12.2.RELEASE</version>
</dependency>

关于spring-java-config - spring data elasticsearch 初始化方法调用失败;嵌套异常是 java.lang.AbstractMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36070229/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com