der*_*ble 18 java deployment netbeans maven netbeans-7
我对这个问题有类似的问题.我已经尝试了列出的所有建议,但仍然不知所措.我的问题是我正在尝试构建一个maven项目并将其分发给其他机器,但jar文件没有填充正确的Manifest.每次我构建和运行时都会出现以下错误:no main manifest attribute, in myjar.jar
.我需要编辑某种配置文件吗?我只是不知道发生了什么.我也试过这个修复,但无济于事.
kof*_*ann 47
您可以将其添加到项目的pom文件中,在<project>
标记内:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<mainClass>your.main.class</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
小智 28
另一种选择是使用maven shade plugin
.与maven jar plugin
tigran显示的不同,它maven shade plugin
包含生成的jar中的依赖项.该插件的示例用法是:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>your.main.Class</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)