猿问

在 maven 上运行时出现 java.lang.NoClassDefFoundError

我从这里运行以下命令

mvn package

包编译成功。

但是当我跑步的时候

java -cp target/cloak-1.0-SNAPSHOT.jar com.github.cloak.App

它给出了以下错误

错误:无法初始化主类 com.github.cloak.App

引起:java.lang.NoClassDefFoundError: boofcv/gui/image/ImagePanel

我编译的方式不对吗?


拉风的咖菲猫
浏览 482回答 2
2回答

回首忆惘然

用 mvn exec:java&nbsp; &nbsp; <build>&nbsp; &nbsp; <plugins>&nbsp; &nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>org.codehaus.mojo</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>exec-maven-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>1.2.1</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <mainClass>com.example.Main</mainClass>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; </plugin>&nbsp; &nbsp; </plugins></build>
随时随地看视频慕课网APP

相关分类

Java
我要回答