pom.xmlを設定してもアプリケーションが実行されず、メインクラスが見つかりませんでした。プラグインを正しく設定した後、メインクラスを見つけられませんでした。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>EditPropertiesFile</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>com.example.EditPropertiesFile.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/commons-configuration/commons-configuration -->
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
</dependency>
</dependencies>
</project>
私が使用するコマンドMVNクリーンコンパイルアセンブリ:here
私のpom.xmlに述べたように 私はセットアップ私のpom.xmlを持つ単一は、アプリケーションをパッケージ化し、その後のjavaでそれを実行するために - これは、そのjarファイル内にあるMANIFEST.MFが、言っていることである
outputedJar.jar jarファイル:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: xxxx
Build-Jdk: 1.8.0_121
Main-Class: com.example.EditPropertiesFile.Main
私が実行したときしかし、私は次のエラーを取得:
Error: Could not find or load main class com.example.EditPropertiesFile.Main
私はすべてのSO上で様々な答えを試してみましたが、それらはすべてが他のいくつかの問題を修正するように見えるように私は、私は試すことができます他に何かわかりません。
EDIT: 出力のコマンドを実行している:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building EditPropertiesFile 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ EditPropertiesFile ---
[INFO] Deleting D:\Users\xxxx\Documents\Java_workspace\EditPropertiesFile\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ EditPropertiesFile ---
[WARNING] Using platform encoding (Cp1250 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\Users\xxxx\Documents\Java_workspace\EditPropertiesFile\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ EditPropertiesFile ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-assembly-plugin:2.4:single (default-cli) @ EditPropertiesFile ---
[WARNING] Cannot include project artifact: com.example:EditPropertiesFile:jar:1.0; it doesn't have an associated file or directory.
[INFO] Building jar: D:\Users\xxxx\Documents\Java_workspace\EditPropertiesFile\target\EditPropertiesFile-1.0-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.525 s
[INFO] Finished at: 2017-08-16T21:17:56+02:00
[INFO] Final Memory: 13M/225M
[INFO] ------------------------------------------------------------------------
jarファイルの内部には、ファイルMain.java
私のプロジェクトの構造が存在しない:
私は今、質問を編集しました。 Main.javaは出力されたjarファイルにありません。 –
ディレクトリ構造が問題であるかどうかわかりません。コマンドラインからmvnを使用している場合は、最後に –
というプロジェクト構造の画像を与えるように編集しました。ディレクトリ構造がmvn defaultに準拠していることを確認する必要があります。私が一度も言及しなかった構造を試してみてください。 – Sharman25