添加 HAL 浏览器时出错:找不到依赖项 'org.springframework.data:spring-data-rest-hal-browser:'
Posted
技术标签:
【中文标题】添加 HAL 浏览器时出错:找不到依赖项 \'org.springframework.data:spring-data-rest-hal-browser:\'【英文标题】:An error while adding HAL Browser: Dependency 'org.springframework.data:spring-data-rest-hal-browser:' not found添加 HAL 浏览器时出错:找不到依赖项 'org.springframework.data:spring-data-rest-hal-browser:' 【发布时间】:2020-11-27 09:07:56 【问题描述】:尝试使用 Spring Boot 安装 Hal 浏览器,但出现以下错误:
Dependency 'org.springframework.data:spring-data-rest-hal-browser:' not found
不知道Spring插件之间的兼容性有没有官方参考,不过不管怎样,这里我默认使用的是最新版本。
这是我的 POM 文件:
...
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.ec</groupId>
<artifactId>explorecali</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>explorecali</name>
<description>Explore California MicroService</description>
<properties>
<java.version>15</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-data-rest</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.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-browser</artifactId>
</dependency>
</dependencies>
...
【问题讨论】:
【参考方案1】:包已重命名为spring-data-rest-hal-explorer
。我验证它与 Spring Boot 2.5.6 兼容。
Maven 示例:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-rest-hal-explorer</artifactId>
</dependency>
Gradle 示例:
implementation('org.springframework.data:spring-data-rest-hal-explorer')
【讨论】:
【参考方案2】:好像是最新版Spring不兼容的问题,解决办法是将Spring Boot降级到2.3.5.RELEASE
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
【讨论】:
以上是关于添加 HAL 浏览器时出错:找不到依赖项 'org.springframework.data:spring-data-rest-hal-browser:'的主要内容,如果未能解决你的问题,请参考以下文章