Netbeans Maven Project Not adding Main Class to Manifest

后端 未结 2 1641
深忆病人
深忆病人 2020-12-13 07:10

I am having a similar problem to this question. I have tried all the suggestions listed and am still at a loss. My issue is that I am trying to build a maven project and dis

相关标签:
2条回答
  • 2020-12-13 07:53

    Another option is to use the maven shade plugin. Unlike the maven jar plugin showed by tigran, the maven shade plugin includes your dependencies in the generated jar. A sample usage of the plugin is :

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>2.0</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                      <mainClass>your.main.Class</mainClass>
                    </transformer>
                  </transformers>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    
    0 讨论(0)
  • 2020-12-13 08:04

    You can add it into project's pom file, inside <project> tag:

    <build>
        <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-jar-plugin</artifactId>
              <version>2.4</version>
              <configuration>
                  <archive>
                      <manifest>
                          <mainClass>your.main.class</mainClass>
                      </manifest>
                  </archive>
              </configuration>
          </plugin>
      </plugins>
    </build>
    
    0 讨论(0)
提交回复
热议问题