java 没有主要清单属性 - IntelliJ

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27982327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 12:45:12  来源:igfitidea点击:

No main manifest attribute - IntelliJ

javaintellij-ideajarmanifest

提问by joey7492

I know there have been many posts on this but I can't seem to find an appropriate solution. So I have my 3 classes, one with a main and from IntelliJ everything runs fine. But I cannot seem to run the .jar file that I have created.

我知道有很多关于这个的帖子,但我似乎找不到合适的解决方案。所以我有我的 3 个课程,一个有一个主要的,来自 IntelliJ 的一切都运行良好。但我似乎无法运行我创建的 .jar 文件。

I also have a manifest file that contains the following:

我还有一个清单文件,其中包含以下内容:

Manifest-Version: 1.0
Main-Class: beanParser

I created the jar through the build option in IntelliJ. Any suggestions?

我通过 IntelliJ 中的构建选项创建了 jar。有什么建议?

Thanks

谢谢

采纳答案by Ronald Duck

Have you considered the following link?

您是否考虑过以下链接

For Maven have a look at the following clipor this one.

对于 Maven,请查看以下剪辑剪辑

Here's a snipped I used in my project:

这是我在项目中使用的片段:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>your.main.Clazz</mainClass>
                        <classpathPrefix>lib/</classpathPrefix>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.8</version>
            <executions>
                <execution>
                    <id>copy-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>copy-dependencies</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                            ${project.build.directory}/lib/
                        </outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

回答by Vladislav

MANIFEST.MF should be in:

MANIFEST.MF 应该在:

src/main/resources/META_INF/

src/main/resources/META_INF/

NOT in:

不在:

src/main/java/META_INF/

src/main/java/META_INF/