【发布时间】:2019-04-26 03:22:06
【问题描述】:
我有我的 IntelliJ maven 项目,我正在尝试构建 jar,但每当我运行它时,它都会抛出 no main manifest attribute, in Project.jar
这是我的 pom.xml 构建。我正在尝试使用我在网上阅读的 Maven 设置清单中的主类,以便在 maven-compiler-plugin 中执行此操作。当我在 WinRar 中打开 jar 时,清单是由 Apache Maven 生成的,但没有得到主类。
<?xml version="1.0" encoding="UTF-8"?>
<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>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<archive>
<manifest>
<mainClass>com.bwfcwalshy.ssbbot.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
-
我很确定编译器插件不能做到这一点(它编译你的代码,不产生 jar)。您需要在您的 jar 包中指定它,可能是 maven-jar-plugin。见maven.apache.org/shared/maven-archiver/examples/classpath.html
标签: maven intellij-idea manifest