简体   繁体   English

java.net.http 导入 - 未找到

[英]java.net.http import - not found

I am working in Intellij with Java 11. I want to use import java.net.http.httpclient in my project but the import statement is not found.我正在使用 Java 11 在 Intellij 工作。我想在我的项目中使用import java.net.http.httpclient但找不到导入语句。

Background:背景:

I am compiling on my Windows 10 Workstation to build for deployment on a Rasp Pi Zero W. The version of Java that I am using (SDK) is Azul Java 11.0.13.我正在我的 Windows 10 工作站上进行编译,以便在 Rasp Pi 零 W 上进行部署。我使用的 Java 版本(SDK)是 Azul ZD52387880E1EA22817A72D3750Z13111。

When I type in import java.net.http.httpclient java.net is found but the http is not.当我输入 import java.net.http.httpclient java.net 但 http 不是。

I have setup Intellij to use Java 11 AFAIK.我已将 Intellij 设置为使用 Java 11 AFAIK。

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

How do I get the import to work?如何让导入工作?

Starting with java 9 if project has module-info.java that's the place were all non-default modules should be declared so that they can be used.从 java 9 开始,如果项目有module-info.java ,那么所有非默认模块都应该被声明以便可以使用。

In your case it'd look as follows:在您的情况下,它看起来如下:

module ModuleName {
    requires java.net.http;
}

For more details you could read:有关更多详细信息,您可以阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM