ClassNotFoundException when 运行 mvn exec:java on Windows

ClassNotFoundException when running mvn exec:java on Windows

我正尝试使用 Maven 通过命令行 运行 我的程序。开始一切的 class 的位置是 projectFolder -> src -> frogger -> game -> MainMenu.java

我已尝试 运行ning mvn evec:java,但出现以下错误:

[WARNING]
java.lang.ClassNotFoundException: frogger.game.MainMenu
    at java.net.URLClassLoader.findClass (URLClassLoader.java:466)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:566)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:499)
    at org.codehaus.mojo.exec.ExecJavaMojo.run (ExecJavaMojo.java:281)
    at java.lang.Thread.run (Thread.java:844)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.510 s
[INFO] Finished at: 2019-12-17T17:50:48Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project mainProject: An exception occured while executing the Java class. frogger.game.MainMenu -> [Help 1]

我已经尝试 运行ning mvn clean install 然后 mvn exec:java 按照此线程中的建议:Class Not Found exception with exec-maven-plugin when run on Linux 但问题仍然存在。

我也试过 运行ning mvn exec:java -D"exec.mainClass"="frogger.game.MainMenu",我在其他地方找到了它,但它给我带来了与上述相同的问题。

编辑:设法通过重新排列我的文件夹结构来匹配 src/main/java

来修复它

按如下操作:

mvn -X clean install exec:java -Dexec.mainClass="frogger.game.MainMenu"