我嘗試在我的 pom.xml 中添加一個依賴項,但事實證明這不是我想要的,所以我在我的 pom.xml 中洗掉了它。
這是我洗掉的
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>Log_In</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
然后,根據我在教程中看到的內容,我在 NetBeans 13 的 Maven 專案中嘗試了Clean選項,現在我丟失了Target檔案夾中的每個子檔案夾,包括我的.class檔案所在的檔案夾。所以我的專案不再運行并且拋出 ClassNotFoundException。
錯誤:無法找到或加載主類 Log_In 原因:java.lang.ClassNotFoundException:Log_In 命令執行失敗。org.apache.commons.exec.ExecuteException:行程退出并出現錯誤:1(退出值:1)在 org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)在 org.apache.commons.exec .DefaultExecutor.execute (DefaultExecutor.java:166) 在 org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:982) 在 org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:929) 在org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:457) 在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) 在 org.apache.maven.lifecycle.internal.MojoExecutor。在 org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:
要查看錯誤的完整堆疊跟蹤,請使用 -e 開關重新運行 Maven。使用 -X 開關重新運行 Maven 以啟用完整的除錯日志記錄。
我完全意識到這是我沒有事先閱讀檔案的錯。請幫助我,任何幫助將不勝感激,謝謝。
uj5u.com熱心網友回復:
在 Maven 構建程序中洗掉和重新創建目標檔案夾完全可以。
您只丟失了生成的類檔案。您的源檔案 (.java) 應該仍然存在,如果您運行完整mvn clean install檔案,它們將被重新編譯并重新創建您的目標檔案夾、.class 檔案和 jar 資產。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/511847.html
上一篇:如何調整JScrollpane中的文本大小-JAVA
下一篇:MouseListener和MouseMotionListener不適用于JPanel里面有JComponents
