无法弄清楚如何使用Spring Data REST端点

问题描述 投票:1回答:1

我得到这个答复:

{
    "timestamp": "2020-04-15T06:39:29.174+0000",
    "status": 404,
    "error": "Not Found",
    "message": "No message available",
    "path": "/api/users"
}

当我在以下位置发送GET请求时:>>

http://localhost:8080/api/users

具有以下@RepositoryRestResource的端点:

@RepositoryRestResource(collectionResourceRel = "api/users", path = "api/users")
public interface UserRestRepository extends CrudRepository<User, Integer> {
}

带有dependencies

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</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>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
</dependencies>

问题是我上面的配置中缺少什么?还有使用Spring Data REST的其他设置吗?

我对Spring Data REST完全陌生。

我正在将此作为响应:{“ timestamp”:“ 2020-04-15T06:39:29.174 + 0000”,“ status”:404,“ error”:“未找到”,“ message”:“没有消息可用”,“路径”:“ / api / users”},当...

spring spring-boot spring-data-rest
1个回答
1
投票

您的所有配置看起来都不错,但是可以通过仅附加以下内容来解决您的问题:

© www.soinside.com 2019 - 2024. All rights reserved.