In your pom.xml add the following plugin:
<build>
<plugins>
<plugin>
<artifactid>maven-assembly-plugin</artifactid>
<configuration>
<archive>
<manifest>
<mainclass>com.mytroubleshootings.MainClass</mainclass>
</manifest>
</archive>
<descriptorrefs>
<descriptorref>jar-with-dependencies</descriptorref>
</descriptorrefs>
</configuration>
</plugin>
</plugins>
</build>
The specified com.mytroubleshootings.MainClass is the class that contains the public static void main method, replace with yours.
Now you can create your jar from command line, be sure "mvn" command is reachable:
mvn clean compile assembly:singleBrowse the directory "target", here will be your jar, i.e. myproject-jar-with-dependencies.jar, you can now execute it running:
java -jar myproject-jar-with-dependencies.jar
No comments:
Post a Comment