2016-05-18 26 views
0

我正在使用Intellij Idea,我创建了一个简单的Maven项目,但是当我创建一个jar文件并使其在终端上运行时,它向我显示错误: “no main manifest属性,在目标/ JMS-1.0-SNAPSHOT.jar “ 我pom.xml的是:获取没有清单属性,在t.jar文件

<?xml version="1.0" encoding="UTF-8"?> 

http://maven.apache.org/xsd/maven-4.0.0.xsd”> 4.0 0.0

<groupId>JMS</groupId> 
<artifactId>JMS</artifactId> 
<version>1.0-SNAPSHOT</version> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>3.0.0</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>test-jar</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
<dependencies> 
    <!-- TEST SCOPE --> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.12</version> 
    </dependency> 
    <dependency> 
     <groupId>commons-lang</groupId> 
     <artifactId>commons-lang</artifactId> 
     <version>2.6</version> 
    </dependency> 
    <dependency> 
     <groupId>com.intellij</groupId> 
     <artifactId>forms_rt</artifactId> 
     <version>7.0.3</version> 
    </dependency> 

    <dependency> 
     <groupId>org.apache.activemq</groupId> 
     <artifactId>activemq-core</artifactId> 
     <version>5.7.0</version> 
    </dependency> 
</dependencies> 

所以,我想知道如何生成一个jar文件。

+0

你真的想创建一个测试罐?我假设不。所以不要通过pluginManagement定义maven-jar-plugin或正确定义目标,除非你真的知道你在做什么。 junit依赖应该在'测试'... – khmarbaise

回答

0

不知道你正在尝试 但您可以添加舱单罐子看https://maven.apache.org/shared/maven-archiver/examples/classpath.html

即插件,你需要指定标签真正

示例代码 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> <classpathPrefix>../../../../../..</classpathPrefix> <classpathLayoutType>repository</classpathLayoutType> <mainClass>com.MainClass</mainClass> </manifest> <manifestEntries> <Implementation-Build>1</Implementation-Build> <Implementation-Version>1.2</Implementation-Version> </manifestEntries> </archive> </configuration> </plugin>

+0

没有得到答案它仍然说入场班不存在 –

+0

_入门课堂?_ –