bash
复制代码
mvn install:install-file -Dfile=D:\protocol.jar -DgroupId=com.gdc -DartifactId=protocol -Dversion=1.0.0 -Dpackaging=jar -DgeneratePom=true
xml
复制代码
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
xml
复制代码
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
xml
复制代码
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
xml
复制代码
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<!-- 存档 -->
<archive>
<manifest>
<!-- 项目启动类 -->
<mainClass>com.goldcard.test.openlink.LoadrunnerOpenlinkApplication</mainClass>
<!-- 依赖的jar的目录前缀 -->
<classpathPrefix>../lib</classpathPrefix>
<!-- 使用唯一版本 -->
<useUniqueVersions>false</useUniqueVersions>
<!-- 添加classpath 开关 -->
<addClasspath>true</addClasspath>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<!-- 配置清单(MANIFEST)属性 -->
<manifestEntries>
<Class-Path>../resources</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
xml
复制代码
<!-- 将依赖包打包到 lib 目录 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!-- 依赖包存放的位置 -->
<outputDirectory>target/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>compile</includeScope>
</configuration>
</execution>
</executions>
</plugin>
xml
复制代码
<!-- 此插件在Maven 多环境切换时,必须添加 -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<inherited>true</inherited>
<configuration>
<encoding>UTF-8</encoding>
<!-- 配置资源文件中的变量分隔符(标识符),这里配置了两种变量分隔符 -->
<delimiters>
<delimiter>${*}</delimiter> <!-- 以${}为分隔符,例如 ${spring.profiles.active} -->
</delimiters>
</configuration>
</plugin>
xml
复制代码
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
<finalName>LoadRunnerOpenlink</finalName>
<mainClass>com.goldcard.test.openlink.LoadrunnerOpenlinkApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
xml
复制代码
<!-- assembly 打包,设置指定的打包方式 -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<!-- assebly 配置文件位置 -->
<descriptor>src/main/assembly/assembly.xml</descriptor>
<!-- 打包之后的文件名称 -->
<finalName>loadRunner-openLink</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>./target</outputDirectory>
<tarLongFileMode>gnu</tarLongFileMode>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!-- 绑定到package生命周期阶段上 -->
<phase>package</phase>
<goals>
<!-- 只运行一次 -->
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
xml
复制代码
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<!--指定main方法-->
<mainClass>com.goldcard.Test</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>