简体   繁体   中英

No main manifest found by JAR, even when declared it in XML

I am trying to generate JAR file of simple program with log4j in Maven. Here is my XML:

    <dependencies>
   <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
      <type>jar</type>
   </dependency>
</dependencies>


<build>   
   <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>path.gui.MainGui</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
    </plugin>   
  </plugins> 
 </build>

I can ensure you that path to my main class IS correct (checked multiple times). Yet, what I am getting after java -jar MyApp.jar is:

   no main manifest attribute, in MyApp.jar

What's wrong? Why am I not getting main attribute?

You are using the assembly plugin where you should use the jar-archiver.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM