SimpleIdentifiableResourceAssembler无法解析为某种类型

问题描述 投票:0回答:3

我正在学习本教程:Spring HATEOAS - Basic Example

我有一个具有以下依赖项的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

java spring spring-boot spring-hateoas maven-dependency
3个回答
1
投票

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-hateoas</artifactId>
    </dependency>

0
投票

HATEOAS依赖项添加在:

enter image description here

但这并没有解决问题


0
投票

即使它有点晚,但对于未来(和困惑)的开发人员:答案只是类

SimpleIdentifiableResourceAssembler

到目前为止还没有被添加到回购中。你必须自己实现这个功能(参见Github issue for this question

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