2016-05-29 77 views
0

尽管代码正在使用“maven clean install”进行编译,并且创建了.jar文件,但在执行它时抱怨“没有主清单属性”,在matrixexplorer-0.0.1中。罐”。我已经添加mainClass标签在我的POM文件,所以我不能明白的问题Maven无法找到执行的主类

这里是我的POM文件,

<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> 

    <version>0.0.1</version> 
    <groupId>at.tugraz.iicm</groupId> 
    <artifactId>matrixexplorer</artifactId> 





    <packaging>jar</packaging> 

    <build> 
    <plugins> 
     <plugin> 
     <groupId>at.tugraz.iicm</groupId> 
      <artifactId>matrixexplorer</artifactId> 

     <configuration> 
      <archive> 
      <manifest> 
       <addClasspath>true</addClasspath> 
       <mainClass>at.tugraz.iicm.matrixexplorer.MatrixExplorerApp</mainClass> 
      </manifest> 
      </archive> 
     </configuration> 

     </plugin> 
    </plugins> 
    </build> 




    <name>matrixexplorer</name> 
    <url>http://maven.apache.org</url> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 

    <dependency> 
    <groupId>org.apache.xmlgraphics</groupId> 
    <artifactId>batik-anim</artifactId> 
    <version>1.8</version> 
    </dependency> 


<dependency> 
    <groupId>colt</groupId> 
    <artifactId>colt</artifactId> 
    <version>1.2.0</version> 
</dependency> 

<dependency> 
    <groupId>net.java.dev.appframework</groupId> 
    <artifactId>appframework</artifactId> 
    <version>1.03</version> 
</dependency> 

<dependency> 
    <groupId>concurrent</groupId> 
    <artifactId>concurrent</artifactId> 
    <version>1.3.4</version> 
</dependency> 

<dependency> 
    <groupId>org.hamcrest</groupId> 
    <artifactId>hamcrest-core</artifactId> 
    <version>1.3</version> 
</dependency> 

<dependency> 
    <groupId>org.swinglabs</groupId> 
    <artifactId>swing-worker</artifactId> 
    <version>1.1</version> 
</dependency> 


<dependency> 
    <groupId>batik</groupId> 
    <artifactId>batik-transcoder</artifactId> 
    <version>1.6-1</version> 
</dependency> 


    </dependencies> 


</project> 

和我的文件夹结构作为图像 enter image description here

+0

您可以解压缩您的jar文件的内容并将Manifest.mf文件内容放入您的问题中吗?为什么它失败的线索应该在那里。 –

+0

也许这将有助于:http://stackoverflow.com/questions/9689793/cant-execute-jar-file-no-main-manifest-attribute –

回答

0

在构建部分,而不是

 <groupId>at.tugraz.iicm</groupId> 
    <artifactId>matrixexplorer</artifactId> 

你需要

<groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-jar-plugin</artifactId> 
    <version>3.0.0</version>