嗨,当我运行mvn包时,程序集插件生成jar名称AnonymousChat-1.0-SNAPSHOT.jar
,然后我认为这应该很好,然后尝试运行此jar,但出现错误“无主清单属性”,这是代码段Maven插件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>com.shell.Terminal</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
答案 0 :(得分:0)
我找到了可以解决问题的代码,如果对某人有用,我在这里写我。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.shell.Terminal</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>