Disons que vous avez un projet Java comme swimsuit :
bundle ms.ao.one thing;
public class MyProject {
public static void most important(String...args) throws Exception {
System.out.println("Whats up world!");
}
}
Maintenant, vous voulez construire ceci et en faire un Jar exécutable autonome.
Si vous faites un mvn clear set up
ou mvn clear bundle
et essayez de l’exécuter comme swimsuit :
java -jar goal/my-java-1.0-SNAPSHOT.jar
Vous obtiendrez l’erreur suivante :
no most important manifest attribute, in goal/my-java-1.0-SNAPSHOT.jar
Remark résoudre no most important manifest attribute
erreur
Vous pouvez résoudre cette erreur en ajoutant ce qui swimsuit dans votre pom.xml
déposer:
<construct>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<model>3.1.1</model>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>ms.ao.one thing.MyProject</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</construct>
Construisez maintenant votre resolution comme ceci :
mvn clear set up bundle
Exécutez ensuite votre Jar autonome comme swimsuit :
java -jar goal/my-java-1.0-SNAPSHOT.jar