Preface
In the previous article on how to use Maven in Eclipse, now it's time to talk about how to use MAVEN to package the jar, after all, our project always needs to be executed, and it needs to run in an environment.
Body
The first is that we have to configure the Pom configuration file to be packaged as a jar, as follows:
<modelVersion>4.0.0</modelVersion>
<groupId>sheldon.com.word</groupId>
< artifactid>wordtest</artifactid>
<packaging>jar</packaging>
<version>0.0.1- snapshot</version>
<name>wordtest Maven webapp</name>
<url>http:// Maven.apache.org</url>
is to define the packaging method, and then there is a more important configuration:
<build> <finalName>wordtest</finalName> <plugins> <plugin> <groupid& Gt;org.apache.maven.plugins</groupid> <artifactId>maven-shade-plugin</artifactId> < version>1.2.1</version> <executions> <execution> <phase>
Package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <
Transformer implementation= "Org.apache.maven.plugins.shade.resource.AppendingTransformer" >
<resource>META-INF/spring.handlers</resource> </transformer>
<transformer implementation= "Org.apache.maven.plugins.shade.resource.AppendingTransformer" > <resource&gT Meta-inf/spring.schemas</resource> </transformer> <transfor Mer implementation= "Org.apache.maven.plugins.shade.resource.ManifestResourceTransformer" > <mai
Nclass>com.wordtest.main.dataremoval</mainclass> </transformer> </transformers> </configuration> </execution> </execution s> </plugin> </plugins> </build>
In this configuration, the only place we need to change is MainClass, which is the address of the class where we need to execute the function.
With these configured, we are ready to compile and pack.
Because this project I was originally in use, I do not execute MVN eclipse:clean eclipse:eclipse, directly execute mvn clean compile.
After the compilation is passed, we need to pack. The command to pack is the Mvn-dmaven.test.skip=true package.
Here, our executable jar package is packed, so let's go to the target folder under the project to find this package.
This executable jar package is already available.