我的pom.xml中有maven-assembly-plugin:
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.xxx.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
因此,在构建项目后,我得到了xxx-1.0-SNAPSHOT.jar可执行文件。因此,当我在终端中运行它时,例如:
$ java -jar xxx.jar
它返回:
no main manifest attribute, in xxx-1.0-SNAPSHOT.jar
答案 0 :(得分:1)
您的内部版本会创建一个其他jar,其名称中包含jar-with-dependencies
。您必须运行此jar。