从 SDN 4.0 迁移到 SDN 4.1.RC1 时出现 GraphQueryLookupStrategy.resolveQuery 异常

2023-12-11

我正在将应用程序迁移到使用 SDN 4.1.0.RC1,但在尝试启动应用程序后遇到了一些问题。我已经进行了必要的配置更改,以正确使用远程服务器 (localhost:7474) 的 HTTPDriver,并且在启动应用程序时,在尝试加载 spring 上下文时,我的存储库之一出现以下错误。

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.data.neo4j.repository.query.GraphQueryLookupStrategy.resolveQuery(Ljava/lang/reflect/Method;Lorg/springframework/data/repository/core/RepositoryMetadata;Lorg/springframework/data/repository/core/NamedQueries;)Lorg/springframework/data/repository/query/RepositoryQuery;
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
    ... 32 common frames omitted
Caused by: java.lang.AbstractMethodError: org.springframework.data.neo4j.repository.query.GraphQueryLookupStrategy.resolveQuery(Ljava/lang/reflect/Method;Lorg/springframework/data/repository/core/RepositoryMetadata;Lorg/springframework/data/repository/core/NamedQueries;)Lorg/springframework/data/repository/query/RepositoryQuery;
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:416)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:206)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
    at org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.afterPropertiesSet(GraphRepositoryFactoryBean.java:43)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    ... 42 common frames omitted

这是似乎在哭泣的 vanilia 存储库

@Repository
public interface UserRepository extends GraphRepository<User> {

  @Query("MATCH (u:User) where u.authId = {authId} return u limit 1")
  User findOneByAuthId(@Param("authId") Long authId);

}

EDIT

看起来这可能是 spring data 和 spring data neo4j 版本之间的脱节。

有问题的 GraphQueryLookupStrategy...

/*
 * Copyright (c)  [2011-2016] "Pivotal Software, Inc." / "Neo Technology" / "Graph Aware Ltd."
 *
 * This product is licensed to you under the Apache License, Version 2.0 (the "License").
 * You may not use this product except in compliance with the License.
 *
 * This product may include a number of subcomponents with
 * separate copyright notices and license terms. Your use of the source
 * code for these subcomponents is subject to the terms and
 * conditions of the subcomponent's license, as noted in the LICENSE file.
 *
 */

package org.springframework.data.neo4j.repository.query;

import org.neo4j.ogm.session.Session;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.repository.core.NamedQueries;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.query.QueryLookupStrategy;
import org.springframework.data.repository.query.RepositoryQuery;

import java.lang.reflect.Method;

/**
 * @author Mark Angrish
 * @author Luanne Misquitta
 * @author Oliver Gierke
 */
public class GraphQueryLookupStrategy implements QueryLookupStrategy {

    private final Session session;

    public GraphQueryLookupStrategy(Session session) {
        this.session = session;
    }

    /* 
     * (non-Javadoc)
     * @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.projection.ProjectionFactory, org.springframework.data.repository.core.NamedQueries)
     */
    @Override
    public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory,
        NamedQueries namedQueries) {
        return new GraphQueryMethod(method, metadata, factory, session).createQuery();
    }
}

我的 QueryLookupStrategy 似乎需要一个方法RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries);显然不是要实施的。我认为这现在是一个依赖问题,并将进一步调查我需要兼容 SDN 的 Spring Data 版本

/*
 * Copyright 2008-2010 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.data.repository.query;

import java.lang.reflect.Method;
import java.util.Locale;

import org.springframework.data.repository.core.NamedQueries;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.util.StringUtils;

/**
 * Strategy interface for which way to lookup {@link RepositoryQuery}s.
 * 
 * @author Oliver Gierke
 */
public interface QueryLookupStrategy {

    public static enum Key {

        CREATE, USE_DECLARED_QUERY, CREATE_IF_NOT_FOUND;

        /**
         * Returns a strategy key from the given XML value.
         * 
         * @param xml
         * @return a strategy key from the given XML value
         */
        public static Key create(String xml) {

            if (!StringUtils.hasText(xml)) {
                return null;
            }

            return valueOf(xml.toUpperCase(Locale.US).replace("-", "_"));
        }
    }

    /**
     * Resolves a {@link RepositoryQuery} from the given {@link QueryMethod} that can be executed afterwards.
     * 
     * @param method
     * @param metadata
     * @param namedQueries
     * @return
     */
    RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries);
}

好的,如果您遇到这个问题,有一个非常直接的方法可以解决它。请参阅以下位置的文档http://projects.spring.io/spring-data/。该异常是由于与spring data commons模块版本冲突引起的。 Neo4j在4.1.0.RC1版本中实现的接口已更改,因此抛出此异常。

要解决此问题,请使用 Spring Data 发布序列 BOM 并将其设置为发布 Hopper-RC1 。由于我使用 gradle,因此说明如下,但您也可以在上面的链接中找到它们。

相关构建脚本简化...

buildscript {
  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:0.4.0.RELEASE"
  }
}

apply plugin: "io.spring.dependency-management"

dependencyManagement {
  imports {
    mavenBom 'org.springframework.data:spring-data-releasetrain:Hopper-RC1'
  }
}

dependencies {
    compile 'org.springframework.data:spring-data-neo4j:4.1.0.RC1'
}repositories {
    maven {
        url 'https://repo.spring.io/libs-milestone'
    }
}

Cheers,

Steve

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

从 SDN 4.0 迁移到 SDN 4.1.RC1 时出现 GraphQueryLookupStrategy.resolveQuery 异常 的相关文章

  • 没有 Neo4Django 的 Django 和 Neo4j

    我正在使用 Neo4j 以及 Postgres 构建一个 Django 应用程序 我发现这个 Django 集成称为新4django https github com scholrly neo4django 我想知道是否可以只使用neo4r
  • 具有空值的 Spring MVC @Path 变量

    Am developing an application using spring boot In Resource am using path variable PathVariable annotation and Request Pa
  • Spring Kafka - 如何使用 @KafkaListener 重试

    来自推特的问题 只是想找到一个使用 spring kafka 2 1 7 的简单示例 该示例与 KafkaListener 和 AckMode MANUAL IMMEDIATE 一起使用 以重试上次失败的消息 https twitter c
  • 实体创建无用的 id 字段

    我有一个CrudRepository与两个实体 Problem 特征实体总是创建一个附加的id数据库中的字段但未选择正确的characteristic id要生成的字段JSON machine entity machine id name
  • Cypher Neo4j 无法加载外部资源

    在 Windows 环境中 我尝试加载带有以下语句的 csv 文件 LOAD CSV WITH HEADERS FROM file E Neo4j customers csv AS row 它似乎无法正常工作并返回 无法加载外部资源 文件
  • Spring Boot 多部分文件始终为 null

    我正在使用 Spring Boot version 1 4 0 RC1 和 Spring Boot Stormpath 1 0 2 我正在尝试使用分段文件上传 但控制器中的 MultipartFile 始终为空 当我使用 RequestPa
  • 如何让 @PostAuthorize 失败导致 @Transactional 回滚?

    我的应用程序中有一些复杂的访问限制 这些限制基本上需要结合用户的角色以及域对象的一些深层属性来做出访问决策 对于我的一些方法 特别是像getItem Integer id and updateItem Integer id FormBean
  • POST 请求“访问此资源需要完全身份验证”

    是否有人在尝试使用 POST 请求 oauth token 进行身份验证时遇到错误 访问此资源需要完全身份验证 卷曲命令 curl localhost 85 oauth token d grant type password d clien
  • OutputCapture 进行多次测试

    我正在使用 org springframework boot test OutputCapture 来测试记录某些内容的注释 它对于单个测试非常有效 当单独运行测试时 如果源文件中存在使用输出捕获的多个测试 但是当多个测试一起运行时 只有第
  • HTTPS 请求仅在 iOS、Ionic 2 上失败

    我有一个Ionic 2调用一个应用程序Spring Boot用于向其他设备发送推送通知的 API API 配置为 HTTPS The API POST请求适用于一切except iOS 我在服务器上的 SSL 证书是自签名的 也许就是这样
  • 我可以为 Spring Boot 应用程序创建多个入口点吗?

    In 春季启动 需要指定一个主类 它是应用程序的入口点 通常 这是一个具有标准 main 方法的简单类 如下所示 SpringBootApplication public class MySpringApplication public s
  • Spring Boot 中的 Spring Security 配置

    我正在努力转换Spring 3项目到Spring 4 Spring 启动 我还不知道这样做是否正确 我转换Spring 安全 XML配置到一个基于Java的配置如下 Configuration EnableWebSecurity publi
  • Spring批量写入器限制

    我正在工作 Spring Batch 项目 从数据库读取记录然后写入rabbitmq 然后发送到HTTP消息网关 网关有150TPS我需要将我的应用程序限制为 150TPS 有没有办法带弹簧批的油门或者还有其他更好的方法吗 你能行的 在 S
  • [TYPE] 类型的 Bean 'x' 不符合所有 BeanPostProcessors 的处理条件

    我有一个ResourceAspect class Component Aspect public class ResourceAspect Before execution public public void resourceAccess
  • 使用 spring-data-neo4j 时如何启用 neo4j webadmin?

    我正在启动一个新项目使用 REST 访问 Neo4j 数据 http spring io guides gs accessing neo4j data rest 例子 该示例使用嵌入式数据库而不是独立的 neo4j 服务器 但我想使用 Ne
  • Spring Boot 开发工具 IntelliJ

    我正在使用 Spring Boot 1 3 0 M5 并且我正在尝试利用 devtools 这允许您在开发过程中对应用程序进行更改 并且启动将重新加载您的应用程序 我已经看到这个演示使用 Java 和 Maven 在 STS 中工作 我正在
  • 分段文件上传:Spring Boot中的大小超出异常返回JSON错误消息

    由于我设置了最大文件上传限制 我得到 org apache tomcat util http fileupload FileUploadBase FileSizeLimitExceededException The field file e
  • spring中如何一起发送@Requestbody和@Requestpart

    我想使用curl 在控制器中一起传递json 和文件 我在控制器中有以下方法 PostMapping value api campaign headers content type multipart mixed content type
  • 从 Spring 启动运行 Java 类

    我使用的是Java8和Spring4 3 1 我有一个 Java Spring 应用程序托管由浏览器和移动应用程序客户端访问的 RESTfult 服务 其次 我编写了一个侦听事件的聊天服务器 socket io 来自客户 该聊天服务器正在从
  • 如何使用@PostConstruct仅在一个实例中调用@Scheduled方法

    有一项工作需要按 cron 计划完成 与作业中相同的逻辑必须在 Spring Boot 应用程序启动时执行 因此使用 PostConstruct 方法 使用 Shedlock 因为计划在多个实例中运行应用程序 问题是 如何使 PostCon

随机推荐