当前位置: 首页 > 知识库问答 >
问题:

java.lang.Abstract方法错误与Spring-数据-弹性搜索

微生良策
2023-03-14

我用的是:

  • 这些版本:
    1. Spring芯 4.3.7
    2. Spring数据弹性搜索 3.0.9 发布
    3. ES:“版本”:“6.3.0”
    4. 组织弹性搜索客户端:rest:5.5.0 和传输 5.5.0
    5. Spring数据共享 1.12.8.发布

创建IAuditElasticRepository.java空接口:

public interface IAuditElasticRepository extends ElasticsearchRepository<AuditDocument, String> {
}

创建了ch-elastic.xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/data/elasticsearch
http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <context:spring-configured />
    <context:annotation-config />
    <elasticsearch:repositories base-package="com.**.ch.db.elasticsearch" />
</beans>

在我的Manager类中自动安装它:

@Autowired
private IAuditElasticRepository elasticRepository;

有一个名为ch-db.xml的父xml将ch-elastic.xml导入其中。

我读过关于abstractMethodError的最新文章,但找不到任何有用的东西。它与我的Spring Core版本有关吗?

堆栈跟踪:

2018-07-30 07:02:25,472 INFO [org.springframework.data.repository.config.RepositoryConfigurationDelegate] - Multiple Spring Data modules found, entering strict repository configuration mode!
2018-07-30 07:02:25,633 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/ch-db.xml]
Offending resource: class path resource [META-INF/ch-ws.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/ch-elasticsearch.xml]
Offending resource: class path resource [META-INF/ch-db.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)

Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/ch-elasticsearch.xml]
Offending resource: class path resource [META-INF/ch-db.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
Caused by: java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/ch-db.xml]
Offending resource: class path resource [META-INF/ch-ws.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/ch-elasticsearch.xml]
Offending resource: class path resource [META-INF/ch-db.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/ch-elasticsearch.xml]
Offending resource: class path resource [META-INF/ch-db.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
Caused by: java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
2018-07-30 07:02:25,650 WARN [org.eclipse.jetty.util.component.AbstractLifeCycle] - FAILED o.e.j.w.WebAppContext{/ws,file:/C:/workspaces/ConnectedHome/Foundation/CH/main/ws/src/main/resources/webapp/}: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/ch-db.xml]
Offending resource: class path resource [META-INF/ch-ws.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/ch-elasticsearch.xml]
Offending resource: class path resource [META-INF/ch-db.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/ch-db.xml]
Offending resource: class path resource [META-INF/ch-ws.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/ch-elasticsearch.xml]
Offending resource: class path resource [META-INF/ch-db.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/ch-elasticsearch.xml]
Offending resource: class path resource [META-INF/ch-db.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/ch-elasticsearch.xml]; nested exception is java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:414)
Caused by: java.lang.AbstractMethodError: org.springframework.data.elasticsearch.repository.config.ElasticsearchRepositoryConfigExtension.getRepositoryFactoryClassName()Ljava/lang/String;
    at org.springframework.data.repository.config.RepositoryBeanDefinitionBuilder.build(RepositoryBeanDefinitionBuilder.java:87)

共有1个答案

颛孙铭
2023-03-14

瓦拉,我有个朋友!!!我也深陷这个问题

但最奇怪的事实是它的工作原理

< code>spring版本==

<代码>Spring数据弹性搜索==

使用这个额外的存储库

<repositories>
    <repository>
        <id>spring-libs-snapshot</id>
        <name>Spring Snapshot Repository</name>
        <url>http://repo.spring.io/libs-snapshot</url>
    </repository>
</repositories>

我认为它不起作用的原因是Spring数据弹性(它使用5以上)和核心Spring版本(我们使用低于5)的Spring数据共享部分的版本冲突

此外,据我所知,弹性服务器6.2仅支持5.6.0以上的传输客户端,因此它也不应支持弹性版本5.5.0

 类似资料:
  • 我需要运行以下查询: 但我不能用spring data elasticsearch轻松运行这个。 有什么办法吗 spring data elasticsearch是否很好地支持所有elasticsearch查询DSL

  • 我有以下映射 以下存储库 但是以下来自spring data elastic search 4.0.3.RELEASE的查询抛出了一个转换错误: [MappingElasticsearchConverter.java:290][Type LocalDateTime of property ElasticDocument.issuedTimestamp是一个临时Accessor类,但既没有定义日期类

  • 升级到Spring boot 2.3和Spring data elasticsearch 4.0.9后的问题。我有这样的文档: 这在spring data 3.0中与Jackson配合得很好,但升级到4.0后,Jackson不再可用,现在我收到了一个来自spring的实例化异常,无法实例化URL对象。 例外情况: 任何关于解决方案的想法都将受到赞赏。

  • 我有一个设计糟糕的文档结构: 我想从上面的文档中检索标题、Fach和代码。 多谢了。

  • 我正在使用spring数据elasticsearch来执行CRUD操作。 我有一个扩展Elasticsearch chRepository的自定义存储库。 最终,ElasticsearchRepository扩展了CrudRepository,这意味着可以更新现有记录。 问题是,你是如何做到这一点的?我还没有找到一个名为“update()”的方法 我认为做以下事情会有用(代码从https://gi

  • 我已经能够通过使用cURL获得建议(参见代码块)。但是我需要在我的代码中这样做,这样我就可以使用我的自定义endpointTOMCAT_ROOT/suggest?q=el。如何使用Spring数据创建查询,以在Java代码中获得相同的结果。 我的es映射: 我的POJO: 我的问题是: 我的查询结果: