LoginSignup
9
6

More than 5 years have passed since last update.

mavenプロジェクトで依存関係を含んだjarファイルを作成する際に「メイン・マニフェスト属性がありません」と言われる際の対処法

Posted at

タイトルの通りですが…。

依存関係を含んでパッケージングする

依存関係もろともパッケージングをするにはmaven-assembly-pluginプラグインを用います。

pom.xmlのproject->build->pluginsの下に追加します。

pom.xml
<build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
            <archive>
              <manifest>
                <mainClass>com.example.App</mainClass>
              </manifest>
            </archive>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
    </plugins>
  </build>

こんな感じ。

jar実行時に「メイン・マニフェスト属性がありません」と言われる

(少なくとも私が試した中では)configuration->archive-manifest->mainClassを指定しないと、タイトルにある「メイン・マニフェスト属性がありません」とjar実行時に言われてしまいました。

9
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
6