无法在Spring Data Rest中示例化Query Predicate

qncylg1j  于 2023-11-16  发布在  Spring
关注(0)|答案(1)|浏览(132)

我不明白Spring为什么要通过接口示例化我的Predicate。**什么配置负责从http参数绑定 predicate ?**我有异常:
找不到接口com. query.core.types.Predicate的主构造函数或单个唯一构造函数
谁知道或看到我的问题?我花了很多时间试图调试这个。提前感谢!
我的控制器:

@RepositoryRestController(path = "/samples")
@RequiredArgsConstructor
public class SamplesController {

    private final PageMapper pageMapper;

    private final SamplesRepository dao;

    @Secured("lab_sample_read")
    @GetMapping
    public PagedModel<Sample> samplesPage(
        SamplesFilter parameters,
        @QuerydslPredicate(root = Sample.class) Predicate predicate,
        Pageable pageable
    ) {
        Page<Sample> page = dao.findAll(parameters, predicate, pageMapper.zeroIndexed(pageable));
        return PagedModel.of(page.getContent(), pageMapper.metaOneIndexed(page));
    }

}

字符串
我的财产:
mvc.servlet.path:/labs
我的依赖项:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.4</version>
</parent>

<groupId>xxx</groupId>
<artifactId>labs-application</artifactId>
<name>Application</name>
<description>Labs Application Module</description>
<packaging>jar</packaging>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <classifier>jakarta</classifier>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <classifier>jakarta</classifier>
    </dependency>

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
    </dependency>
    <dependency>
        <groupId>org.mapstruct</groupId>
        <artifactId>mapstruct</artifactId>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
    </dependency>

    <!-- todo restore -->
    <!-- <dependency> -->
    <!--     <groupId>org.springdoc</groupId> -->
    <!--     <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> -->
    <!-- </dependency> -->
</dependencies>

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
        </resource>
    </resources>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
        </testResource>
    </testResources>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <addResources>true</addResources>
            </configuration>
        </plugin>

        <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>apt-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <configuration>
                        <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>


我的日志与bean的条件和记录所有注册:https://pastebin.com/wgkHc7Xi

f87krz0w

f87krz0w1#

好吧,这是spring data rest的问题,它在@RestController上工作过,但在@ReositoryRestController上没有。https://github.com/spring-projects/spring-data-rest/issues/1210

相关问题