Using maven we can create executable JAR file with all the requires dependencies and then we can use that JAR file to execute the whole project. So, to create the JAR file just add the below plugin inside the build tag.
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Now after installing the desired desired dependencies through <b>mvn install</b>, launch the goal to create the JAR file.
mvn clean compile test assembly:single
The executable JAR file will be created inside the "Target" folder of project directory.
0 Comment(s)