java 无法运行 .jar,因为“没有主要清单属性”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46695661/
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
Can't run .jar because "no main manifest attribute"
提问by NateH06
I've never built an executable .jar before, and I'm trying to do so with a Maven project with IntelliJ, and I can't seem to run the program. I've done it through the Project Structure -> artifacts route, and I've set the main class and locations properly or so I thought, in the configuration:
我以前从未构建过可执行文件 .jar,我正在尝试使用 IntelliJ 使用 Maven 项目来构建,但我似乎无法运行该程序。我已经通过 Project Structure -> artifacts 路线完成了它,并且我已经在配置中正确设置了主类和位置,或者我认为:
in my pom.xml
在我的pom.xml
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>spring-boot</classifier>
<mainClass>
app.ContactRunner
</mainClass>
</configuration>
</execution>
</executions>
</plugin>
And here's a screenshot of the project structure along with the MANIFEST.MF
这是项目结构的屏幕截图以及 MANIFEST.MF
What's missing that I need to add in order to execute this jar? Thanks for the help!
为了执行这个 jar,我需要添加什么?谢谢您的帮助!
EDIT-=-=-=
编辑-=-=-=
I have removed the packaging structure, and it is now just app.ContactRunner
with nothing extra in the MANIFEST file.
我已经删除了打包结构,现在它app.ContactRunner
在 MANIFEST 文件中没有任何额外的内容。
采纳答案by NateH06
I had to move where the MANIFEST folder was. It was putting it under
我不得不移动到 MANIFEST 文件夹所在的位置。它把它放在下面
/src/main/java/
/src/main/java/
and it needed to be under
它需要在
/src/main/resources
/src/main/resources
As taken from this answer: https://stackoverflow.com/a/21074091/7082628