无法使vertx对象无法接受

问题描述 投票:1回答:1

我在尝试使用vertx时遇到了一些麻烦。我正在使用IntelliJ在Windows上开发。我只是想尝试一个vertx对象,如下所示:vertx vertx = Vertx.vertx()

在Windows上运行int时,我收到有关netty的警告:

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil (file:/C:/Users/souki/.m2/repository/io/netty/netty-common/4.1.19.Final/netty-common-4.1.19.Final.jar) to constructor java.nio.DirectByteBuffer(long,int)
WARNING: Please consider reporting this to the maintainers of io.netty.util.internal.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

但应用程序不会停止并正常工作。但由于某些原因,我无法在Windows上测试我的程序,并且必须在Linux VM上运行它。

按照java -jar myjar.jar在VM上运行它时,我收到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: io/vertx/core/Vertx
        at Ecmg.main(Ecmg.java:16)
Caused by: java.lang.ClassNotFoundException: io.vertx.core.Vertx
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 1 more

当我删除Vertx vertx = Vertx.vertx();时,一切正常。

我的问题是,为什么我在Linux上出现此错误?

如果你想知道,linux上的java -version输出是:

OpenJDK Runtime Environment (build 1.8.0_20-b26)
OpenJDK Server VM (build 25.20-b23, mixed mode)

这是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>JavaEcmg</groupId>
    <artifactId>JavaEcmg</artifactId>
    <version>1.0-SNAPSHOT</version>


    <dependencies>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
            <version>3.5.1</version>
        </dependency>
    </dependencies>

</project>

关于我的Intellij配置:

enter image description here

enter image description here enter image description here

提前致谢!

java intellij-idea vert.x
1个回答
1
投票

关于JVM警告:欢迎使用Java 9和10 :-)(但是,它工作正常)

你可能会得到一个ClassNotFoundException,因为Jar只是你的代码类。尝试建造一个胖罐子,就像在https://github.com/vert-x3/vertx-examples/tree/master/fatjar-examples

© www.soinside.com 2019 - 2024. All rights reserved.