java.lang.classnotfoundexception:org.mockserver.version.version
我正在尝试使用Mockserver-netty-5.13.2
启动模拟服务器 Java版本: 11.0.9
像这样的粗糙外壳代码:
java -version
echo "start shell before java -jar line"
java -jar ./mockserver-netty-5.13.2.jar -serverPort 9090 -logLevel DEBUG &> ${DIR}/mockserver.log
从java -jar./mockserver-netty-5.13.2.2.2.2.2.2.jar -serverport 9090
引发的异常
Exception in thread "main" java.lang.NoClassDefFoundError: org/mockserver/version/Version
at org.mockserver.cli.Main.<clinit>(Main.java:27)
Caused by: java.lang.ClassNotFoundException: org.mockserver.version.Version
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
。 任何帮助将不胜感激!!!
I am trying to start mock server with mockserver-netty-5.13.2
from shell,
java version:
11.0.9
Rough shell code like this:
java -version
echo "start shell before java -jar line"
java -jar ./mockserver-netty-5.13.2.jar -serverPort 9090 -logLevel DEBUG &> ${DIR}/mockserver.log
The exception thrown from java -jar ./mockserver-netty-5.13.2.jar -serverPort 9090
Exception in thread "main" java.lang.NoClassDefFoundError: org/mockserver/version/Version
at org.mockserver.cli.Main.<clinit>(Main.java:27)
Caused by: java.lang.ClassNotFoundException: org.mockserver.version.Version
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
Has anyone run into this issue and resolved it ?
Any help would be much appreciated !!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够在非常相似的环境中复制问题。
问题是因为您使用错误的罐子。
要从命令行运行
MOCKSERVER
您应该使用-Shaded
jar ,其中包括依赖关系。您使用的JAR不包括所需的依赖项,并且不应在命令行中运行它,而无需手动提供作为
class Path的一部分
的一部分。您收到的错误
几乎支持了此结论,并告诉您
org.mockserver.version.version.version.version
class在您运行此特定JAR时不会提供。在这里,是指示您应该使用阴影罐运行的官方文档从命令行。
< “>这里您可以下载MockServer
5.13.2
阴影jar。然后,像希望有帮助的希望一样运行它
!
I was able to replicate the problem within a very similar environment as yours.
The issue is caused because your are using the wrong jar.
To run the
mockserver
from the command line you should use a-shaded
jar, where it's dependencies are included.The jar you are using does not include the required dependencies and it is not supposed to be ran in the command line without providing them by hand as part of the
classpath
.The error you get
pretty much supports this conclusion, and tells you that the
org.mockserver.version.Version
class is not provided when you run this specific jar.Here, is the official docs that indicate you should use the shaded jar to run mockserver from the command line.
Here you can download the mockserver
5.13.2
shaded jar.Then, run it like this
Hope that helps!