我正在使用 java 11 http 客户端,我需要发送一个没有正文的 post 请求。
HttpRequest request = getRequestBuilder()
.uri(urlBuilder.toURL().toURI())
.POST(HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> httpResponse = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
Run Code Online (Sandbox Code Playgroud)
当我按照上面的方法尝试时,我收到 411 错误代码。我还尝试将“Content-Length”标头设置为“0”,但发现这是受到限制的。
然后我尝试了这个:
URL url = new URL(getHost());
Map<String,Object> params = new LinkedHashMap<>();
params.put("trackingNo", orderPackage.getCargoTrackingCode());
params.put("referenceNo", orderPackage.getCargoCode());
StringBuilder postData = new StringBuilder();
for (Map.Entry<String,Object> param : params.entrySet()) {
if (postData.length() != 0) postData.append('&');
postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
postData.append('=');
postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
}
byte[] postDataBytes = postData.toString().getBytes("UTF-8");
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), …Run Code Online (Sandbox Code Playgroud) 我尝试使用此命令运行反应本机应用程序。
npx react-native run-android --variant=stagingDebug --appId com.xx_staging
Run Code Online (Sandbox Code Playgroud)
但我收到此错误消息。我想在我的机器上运行多个java版本。我怎样才能做到这一点?我也不想更改MaxPermSize=512m。我想保持MaxPermSize=512m不变。
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 2228 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
'"adb"' is not recognized as an internal or external command,
operable program or batch file.
info Launching emulator...
error Failed to launch emulator. Reason: No emulators found …Run Code Online (Sandbox Code Playgroud) 我知道Java 11还没有正式发布,但有没有人用Java 11的早期访问版本测试Grails 3.x?或者有谁知道Grails 3.x何时或是否支持Java 11?
我正在尝试将应用程序从Java 8迁移到Java 11.当我尝试在IntelliJ中构建项目时,我收到package sun.util does not exist错误?
关于什么事情的任何想法?
谢谢!
我正在尝试在我的 macOS 10.14 系统上运行mqtt-spy-1.0.0.jar,但它无法启动,返回以下错误消息:

据开发人员称,如果系统上缺少 JavaFX,则会导致此问题。
如下所示,我的系统上安装了最新版本的 Oracle JDK,但是,我知道 Oracle 已从 v11 中的 JDK 中排除了 JavaFX。
所以我从 GluonHQ下载了JavaFX并按照他们的说明开始。
尽管在 ~/.bash_profile 中正确设置了两个必需的变量,但 mqtt-spy-1.0.0.jar 仍然返回第一个屏幕截图中显示的错误消息......
我还需要做什么或者我需要做什么不同的事情来运行 mqtt-spy?
我有这两种方法:
@Override
public void done(E e, Map.Entry<String, T> m) {
}
@Override
public void done(E e, String k, T v) {
this.done(e, null);
}
Run Code Online (Sandbox Code Playgroud)
而不是传递null,我如何创建一个新的Map.Entry?我试过了:
this.done(e, Map.of(k,v));
Run Code Online (Sandbox Code Playgroud)
但是这会创建一个Map而不是Map.Entry.
我的应用程序正在使用OpenJDK 11,但失败,但出现以下异常:
Caused by: java.lang.IllegalArgumentException: Unsupported CipherSuite: SSL_RSA_WITH_AES_256_CBC_SHA256
at java.base/sun.security.ssl.CipherSuite.validValuesOf(CipherSuite.java:916)
at java.base/sun.security.ssl.SSLSocketImpl.setEnabledCipherSuites(SSLSocketImpl.java:302)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.makeSocketSecure(RemoteTCPConnection.java:2084)
Run Code Online (Sandbox Code Playgroud)
我不共享任何代码,因为我认为问题不存在。我需要以某种方式解决此异常。
是否可以将JRE配置为支持此特定CipherSuite?
我无法在我的 tomcat 9.0.12 服务器上运行我的 java servelet,因为它无法处理类版本。我收到以下错误:
Error: MyClass been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class
Run Code Online (Sandbox Code Playgroud)
我用 java 11 编译了我的代码:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
当我在终端中输入: java -version 时,我得到:
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
Run Code Online (Sandbox Code Playgroud)
和 …
在Java 11中,有一组静态方法java.util.Map可以实例化AbstractImmutableMap:
static <K, V> Map<K, V> of(K k1, V v1) { return new Map1(k1, v1); }
static <K, V> Map<K, V> of(K k1, V v1, K k2, V v2) { return new MapN(new Object[]{k1, v1, k2, v2}); }
// ... some more "vararg" static methods until 10 pairs (inclusive).
Run Code Online (Sandbox Code Playgroud)
还有另一种方法,除了true-vararg之外,几乎相同:
static <K, V> Map<K, V> ofEntries(Map.Entry<? extends K, ? extends V>... entries) { /* impl here */ }
Run Code Online (Sandbox Code Playgroud)
我想使用后一种方法,因为它允许将条目数扩展到远远超过十个。问题是,我不知道如何创建Map.Entry。它在不同的Maps中有很多实现,但是没有new运算符或静态构造方法,但是 …
java-11 ×10
java ×9
java-8 ×2
eclipse ×1
grails ×1
grails-3.3.x ×1
hashmap ×1
http ×1
httpclient ×1
java-7 ×1
javafx ×1
macos ×1
macos-mojave ×1
openjdk-11 ×1
post ×1
tomcat ×1