Last active
March 17, 2019 03:29
-
-
Save jahentao/d35d751e3605a7932a9022fcbdab0f1f to your computer and use it in GitHub Desktop.
maven插件打包可执行jar和依赖示例 #Maven
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 一段maven插件打包可执行jar和相应依赖到./lib的示例 --> | |
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>microservice.demo.training21days</groupId> | |
<artifactId>helloworld-provider</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<properties> | |
<cse.version>2.3.62</cse.version> | |
<main.class>microservice.demo.training21days.provider.AppMain</main.class> | |
</properties> | |
<dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>com.huawei.paas.cse</groupId> | |
<artifactId>cse-dependency</artifactId> | |
<version>${cse.version}</version> | |
<type>pom</type> | |
<scope>import</scope> | |
</dependency> | |
</dependencies> | |
</dependencyManagement> | |
<dependencies> | |
<dependency> | |
<groupId>com.huawei.paas.cse</groupId> | |
<artifactId>cse-solution-service-engine</artifactId> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.1</version> | |
<configuration> | |
<compilerArgument>-parameters</compilerArgument> | |
<encoding>UTF-8</encoding> | |
<source>1.8</source> | |
<target>1.8</target> | |
</configuration> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-dependency-plugin</artifactId> | |
<version>2.10</version> | |
<executions> | |
<execution> | |
<id>copy-dependencies</id> | |
<phase>package</phase> | |
<goals> | |
<goal>copy-dependencies</goal> | |
</goals> | |
<configuration> | |
<outputDirectory>target/lib</outputDirectory> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-jar-plugin</artifactId> | |
<version>2.6</version> | |
<configuration> | |
<archive> | |
<manifest> | |
<addClasspath>true</addClasspath> | |
<classpathPrefix>./lib/</classpathPrefix> | |
<mainClass>${main.class}</mainClass> | |
<addDefaultImplementationEntries>true</addDefaultImplementationEntries> | |
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> | |
</manifest> | |
<manifestEntries> | |
<Class-Path>.</Class-Path> | |
</manifestEntries> | |
</archive> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment