1

我正在关注本教程:Spring HATEOAS - 基本示例

我有一个具有以下依赖项的 spring boot 项目:

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</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-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-data-rest</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.9.0</version>
    </dependency>
</dependencies>

本教程显示 Spring HATEOAS 提供 SimpleIdentifiableResourceAssembler 作为执行转换的最简单机制。

问题是我无法从 org.springframework.hateoas 包中解析“SimpleIdentifiableResourceAssembler”类。它抛出一个SimpleIdentifiableResourceAssembler cannot be resolved to a type

4

3 回答 3

3

尽管有点晚了,但对于未来(和困惑)的开发人员来说:答案很简单,就是 Class

SimpleIdentifiableResourceAssembler

到目前为止还没有添加到回购中。您必须自己实现该功能(请参阅此问题的 Github 问题

于 2018-09-05T15:30:56.877 回答
1

HATEOAS 依赖添加在:

在此处输入图像描述

但这并不能解决问题

于 2018-02-26T11:41:06.053 回答
0

您的项目中没有 HATEOAS 依赖项。

添加

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>
于 2018-02-25T17:43:57.597 回答