【发布时间】:2020-11-30 17:19:27
【问题描述】:
我的 Spring Boot 应用程序需要调用 RESTful 服务,我想使用 apache HttpClient 来执行此操作。我在 pom.xml 中添加了依赖(尝试了不同的版本)
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0</version>
</dependency>
但即使我可以看到在构建过程中下载了 .jar 文件:
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.0/httpclient-4.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.0/httpclient-4.0.pom (6.0 kB at 14 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.0/httpcomponents-client-4.0.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.0/httpcomponents-client-4.0.pom (9.8 kB at 138 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.0/httpclient-4.0.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.0/httpclient-4.0.jar (290 kB at 1.1 MB/s)
但在代码中我无法访问它的任何内容:
我在这里错过了什么?
【问题讨论】:
-
我假设您使用的是 IntellJ?从命令行运行“mvn install”会发生什么?
-
构建成功了吗?如果是这样,使缓存无效并重新启动 IntelliJ
-
是的,构建总是成功的,但是通过 maven 导入时我无法使用 HttpClient。
-
在 IntelliJ 中有一个选项可以使缓存无效并重新启动。这样该项目将被重新索引并且导入可能会得到解决
-
我会试试的。 .jar 文件已正确下载,我可以在本地存储库中看到它们。 Intellij 无法访问它们..
标签: java spring-boot maven