DevOps / Maven Interview questions II
Create an executable JAR with dependencies using Maven.
To build an executable jar using maven, we need to add manifest configuration to the maven-assembly-plugin.
The below subset of pom.xml configure maven-assembly-plugin to create a single executable jar.
<build> <plugins> <!-- Build an executable JAR --> <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>fully-qualified-MainClass</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> </plugins> </build>
More Related questions...