gpt4 book ai didi

java - 如何执行Quickfix/J jar?

转载 作者:行者123 更新时间:2023-12-01 21:13:19 24 4
gpt4 key购买 nike

我正在使用quickfix/j 库构建一个独立的交易模拟器。到目前为止,我一直在使用 mvn 包,然后使用 intelli J“运行按钮”从客户端应用程序类中的入口点运行我的程序。我尝试使用 java -jar target/.....1.1.0.jar 。并得到以下错误

java -jar Broker/target/Broker-1.0.0.jar
Error: Could not find or load main class Broker.ClientApplication
Caused by: java.lang.NoClassDefFoundError: quickfix/Application

我认为该错误可能与我的 pom 文件未正确获取依赖项有关。因此,为了确保我运行了来自 fastfix/J github 的 ordermatch 示例,但我收到了类似的错误。

java -jar /homes/antonga/IdeaProjects/Desktop/quickfixj-parent/quickfixj-examples/ordermatch/target/quickfixj-examples-ordermatch-2.1.1-sources.jar

no main manifest attribute, in /homes/antonga/IdeaProjects/Desktop/quickfixj-parent/quickfixj-examples/ordermatch/target/quickfixj-examples-ordermatch-2.1.1-sources.jar

需要明确的是,即使对于 ordermacth 示例,使用主类中的 Intellli J“运行”按钮也能完美工作。据我收集,IntelliJ 使用的命令是这样的“/path/to/java/”“-javagent/.../.jar”“/pathtolocalmavenrepo/quickfix-core.jar”/pathtolocalmavenrepo/anotherquickfixdependecy.jar“.....”更多quickfix依赖jar文件”packagestruct.Main

我不明白为什么这会起作用,但我的执行却不起作用。如果有帮助的话,我可以包含我的 pom 文件和其他信息。我也在使用多模块 Maven 项目,但这似乎不是问题。

最佳答案

原来我是个菜鸟。 Maven 包生命周期将不带依赖项的指定类文件捆绑到 jar 中。我需要创建一个包含所有必要的 bianries 的 uber jar,然后运行它。请参阅SO问题create excecutable jar with dependencies using maven

需要满足以下条件:

java -classpath <list-of-all-jars> <main-class>

哪里<list-of-all-jars>是一个; (Windows) 或 : (*nix) 运行程序所需的所有 jar 的分隔列表(quickfixj jar、您自己的 jar 和所需的任何 jar),以及 <main-class>是主类的完全限定类名(具有应用程序主入口的类)

关于java - 如何执行Quickfix/J jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58891596/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com