【问题标题】:Getting No manifest attribute, in t.jar file在 t.jar 文件中获取无清单属性
【发布时间】:2016-09-15 02:49:55
【问题描述】:

我正在使用 Intellij Idea,并且我创建了一个简单的 maven 项目,但是当我创建一个 jar 文件并使其在终端上运行时,它显示错误: “在 target/JMS-1.0-SNAPSHOT.jar 中没有主要清单属性” 我的 pom.xml 是:

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

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.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 文件。

【问题讨论】:

  • 你真的要创建一个 test-jar 吗?我假设没有。所以不要定义 maven-jar-plugin 或通过 pluginManagement 正确定义,而不是目标执行,除非你真的知道你在做什么。 junit 依赖应该在&lt;scope&gt;test&lt;/scope&gt;...

标签: maven jar


【解决方案1】:

不确定你在尝试什么 但是您可以将清单添加到 jar 中,请参阅https://maven.apache.org/shared/maven-archiver/examples/classpath.html

即在插件中您需要指定标签 true

示例代码 <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>

【讨论】:

  • 没有得到答案它仍然说入学课程不存在
  • 录取等级?
猜你喜欢
  • 2017-08-18
  • 1970-01-01
  • 2013-05-07
  • 2016-07-15
  • 2019-08-11
  • 1970-01-01
  • 2021-04-23
  • 2020-07-28
  • 2021-07-02
相关资源
最近更新 更多