我知道,这是重复的问题,但问题是新的,请不要标记重复的问题.这个程序在Window 10中运行它运行正常并创建一个数据库,但是当在Debian 9中运行相同的程序时它会抛出异常.之后,我在谷歌上检查了这个问题.有人说,创建一个所有用户类状态的setter和getter方法.我创建了一个setter和getter方法,但抛出了同样的异常.
用户类
@Entity
public class User {
@Id
private Long id;
private String firstName;
private String lastName;
private String professional;
private int age;
public User() {}
public User(Long id, String firstName, String lastName, String professional, int age) {
this.id = id;
this.firstName = firstName;
this.lastName = lastName;
this.professional = professional;
this.age = age;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public …Run Code Online (Sandbox Code Playgroud) 我需要很快将应用程序升级到Java 11,我想知道与Java 11兼容的最小Spring版本是什么.
我目前正在使用Java 8和Spring 4.2.7.
我收到以下错误,因为Java 11将JavaFX排除在最新版本的一部分之外.
Run Code Online (Sandbox Code Playgroud)Error: JavaFX runtime components are missing, and are required to run this application
那么如何在Java 11中将JavaFX添加到Eclipse?谢谢.
在我们的应用程序中,我们有时会遇到以下异常:
javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
Run Code Online (Sandbox Code Playgroud)
我们已经发现只有当我们使用时才会发生这种情况,Collection.parallelStream()但如果我们使用Collection.stream().
我们看到 JAXBThread.currentThread().getContextClassLoader()用于加载类。我们还看到,当使用 时parallelStream(),执行我们命令的线程使用不同的类加载器。有时是org.apache.catalina.loader.WebappClassLoader,有时是jdk.internal.loader.ClassLoaders.AppClassLoader。
现在看来,AppClassLoader不知道 JAXB 依赖项,而WebappClassLoader。
我们正在使用 Java 11 和以下 Maven 依赖项:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
知道有什么问题吗?怎么可能,AppClassLoader不知道我们的依赖关系?
在P下面的类中,该方法test似乎返回相同false:
import java.util.function.IntPredicate;
import java.util.stream.IntStream;
public class P implements IntPredicate {
private final static int SIZE = 33;
@Override
public boolean test(int seed) {
int[] state = new int[SIZE];
state[0] = seed;
for (int i = 1; i < SIZE; i++) {
state[i] = state[i - 1];
}
return seed != state[SIZE - 1];
}
public static void main(String[] args) {
long count = IntStream.range(0, 0x0010_0000).filter(new P()).count();
System.out.println(count);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,将 classP与结合使用 …
我无法使用Java 11和最新版本的maven-compiler-plugin构建.
pom.xml中:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugins>
<build>
Run Code Online (Sandbox Code Playgroud)
当我尝试使用Maven构建时:
? mvn clean compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building service 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ service ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 80 source files to /home/mip/service/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.859 s
[INFO] Finished at: 2018-08-01T11:20:55+01:00
[INFO] Final Memory: 32M/124M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to …Run Code Online (Sandbox Code Playgroud) 我刚刚在Windows 10上安装了OpenJDK版本的JDK 11通用可用性版本.我尝试在刚刚发布的Eclipse 2018-09(4.9.0)中将其作为JRE安装,并在Eclipse对话框中显示一条消息:
您选择了此版本的Eclipse JDT尚未完全支持的JRE.某些功能可能无法正常工作.
问题是什么?
更新:从Internet搜索,我发现一些代码似乎表明Eclipse有一个已知Java版本的内部列表,如果新的JDK版本的版本高于已知的Java版本,它会给出上述消息.(这就是我解释代码的方式.)真的吗?Eclipse发布了一个新的2018-09版本,就在JDK 11发布前几天,没有更新其已知Java版本列表以包含Java 11?
也许有人有更权威的答案.
我正在尝试构建使用Java 8构建的应用程序,现在已升级到Java11。我在Windows计算机中使用oracle文章安装了Java 11,并使用IntelliJ IDEA 2017作为IDE。
我更改了系统环境变量并设置了
JAVA_HOME to C:\Program Files\Java\jdk-11.0.1
Run Code Online (Sandbox Code Playgroud)
并将其添加到Path变量中。
C:\>java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)
Run Code Online (Sandbox Code Playgroud)
当我在IntelliJ中构建应用程序时,这是我得到的:
Information:java: Errors occurred while compiling module 'test-domain_main'
Information: javac 1.8.0_171 was used to compile java sources
Information:1/10/2019 4:21 PM - Compilation completed with 1 error and 0 warnings in 1s 199ms
Error:java: invalid target …Run Code Online (Sandbox Code Playgroud) 同时使用 Java 8 和 Java 11,请考虑以下TreeSet带有String::compareToIgnoreCase比较器的内容:
final Set<String> languages = new TreeSet<>(String::compareToIgnoreCase);
languages.add("java");
languages.add("c++");
languages.add("python");
System.out.println(languages); // [c++, java, python]
Run Code Online (Sandbox Code Playgroud)
当我尝试删除 中存在的确切元素时TreeSet,它起作用了:所有指定的元素都被删除:
languages.removeAll(Arrays.asList("PYTHON", "C++"));
System.out.println(languages); // [java]
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试删除而不是 中存在的更多TreeSet,则调用根本不会删除任何内容(这不是后续调用,而是调用而不是上面的代码段):
languages.removeAll(Arrays.asList("PYTHON", "C++", "LISP"));
System.out.println(languages); // [c++, java, python]
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?为什么会这样?
编辑:String::compareToIgnoreCase是一个有效的比较器:
(l, r) -> l.compareToIgnoreCase(r)
Run Code Online (Sandbox Code Playgroud) 我在将纯 Kubernetes 应用程序迁移到 Istio 托管时遇到问题。我正在使用 Google Cloud Platform (GCP)、Istio 1.4、Google Kubernetes Engine (GKE)、Spring Boot 和 JAVA 11。
我让容器在纯 GKE 环境中运行,没有出现任何问题。现在我开始将 Kubernetes 集群迁移到使用 Istio。从那时起,当我尝试访问公开的服务时,我收到以下消息。
上游连接错误或在标头之前断开/重置。重置原因:连接失败
该错误消息看起来非常普通。我发现了很多不同的问题,具有相同的错误消息,但没有人与我的问题相关。
下面是 Istio 的版本:
client version: 1.4.10
control plane version: 1.4.10-gke.5
data plane version: 1.4.10-gke.5 (2 proxies)
Run Code Online (Sandbox Code Playgroud)
下面是我的 yaml 文件:
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
account: tree-guest
name: tree-guest-service-account
---
apiVersion: v1
kind: Service
metadata:
labels:
app: tree-guest
service: tree-guest
name: tree-guest
spec:
ports:
- name: http
port: 8080
targetPort: 8080
selector:
app: tree-guest
--- …Run Code Online (Sandbox Code Playgroud) java-11 ×10
java ×9
java-8 ×2
spring ×2
spring-boot ×2
arrays ×1
classloader ×1
comparator ×1
eclipse ×1
hibernate ×1
istio ×1
java-stream ×1
javafx-11 ×1
jaxb ×1
kubernetes ×1
linux ×1
maven ×1
simd ×1
treeset ×1
ubuntu ×1