【问题标题】:accessing data from application.properties inside an interface从接口内的 application.properties 访问数据
【发布时间】:2018-11-03 19:24:23
【问题描述】:

我想限制一些查询的结果

application.properties

...
spring.neo4j.resultlimit=10
...

PersonRepository

public interface PersonRepository extends GraphRepository<Person> {

    @Query("MATCH p=()-->() RETURN nodes(p) as n, relationships(p)[0] as e") //<--how can I access spring.neo4j.resultlimit value and limits this query?
    Iterable<Map<String, String>> graph();
}

【问题讨论】:

    标签: spring spring-boot neo4j spring-data spring-data-neo4j


    【解决方案1】:

    您的 Spring 客户端可以获取 spring.neo4j.resultlimit 的值并将其传递给 graph() 方法,可以这样定义:

    public interface PersonRepository extends GraphRepository<Person> {
        @Query("MATCH p=()-->() RETURN nodes(p) as n, relationships(p)[0] as e LIMIT {0}")
        Iterable<Map<String, String>> graph(Integer resultLimit);
    }
    

    【讨论】:

    • 是的,如果可能的话,我想避免这种普遍的变化(我必须更改很多方法)..没有办法直接在界面中读取该值?
    猜你喜欢
    • 1970-01-01
    • 2021-11-21
    • 1970-01-01
    • 2021-07-27
    • 1970-01-01
    • 1970-01-01
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多