因此,我正在遵循有关使用Spring Boot构建Restful服务的教程,我必须将HATEOAS依赖项添加到pom.xml中,但是它没有用!<?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>2.2.4.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.project</groupId><artifactId>Project</artifactId><version>0.0.1-SNAPSHOT</version><name>Project</name><description>Demo project for Spring Boot library management system</description><properties><java.version>1.8</java.version></properties><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-web</artifactId></dependency><dependency><groupId>com.h2database</groupId><artifactId>h2</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-hateoas</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>这就是我得到的错误enter image description here而我的目标是使用无法导入的org.springframework.hateoas.Resource中的Resource ! enter image description here请帮忙 (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 Resource在Spring Hateoas 1.0中已重命名为EntityModel,因此您正在寻找org.springframework.hateoas.EntityModel资料来源:https://docs.spring.io/spring-hateoas/docs/current/reference/html/#migrate-to-1.0.changes.representation-models:  类的ResourceSupport / Resource / Resources / PagedResources组  从来没有真正感到过合适的名字。毕竟,这些类型不  实际上体现了资源,而是表示模型,可以  超媒体信息和能力丰富。就是这样  新名称映射到旧名称:    ResourceSupport现在是RepresentationModel    资源现在是EntityModel    资源现在是CollectionModel    现在,PagedResources是PagedModel关于java - 无法将Spring HATEOAS添加到pom.xml,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60058442/ (adsbygoogle = window.adsbygoogle || []).push({});
10-10 04:43