pom文件
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!-- 复制第三方 jar 到项目目录下的 target/lib/ 下 -->
<execution>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<excludeScope>provided</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<!-- 指定 Spring Boot 启动类,实际测试中必须 -->
<mainClass>com.example.ems.EmsApplication</mainClass>
<!-- 将所有第三方 jar 添加到项目 jar 的 MANIFEST.MF 文件中,这样运行 jar 时依赖包才能被加载 -->
<addClasspath>true</addClasspath>
<!-- 指定复制第三方 jar 的目标目录为 target/lib/-->
<classpathPrefix>./lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
运行maven---lifecycle--package命令 会在target生产lib 和jar
2上传到linux 我的是/java/jar 里面
运行 注意在win系统里面运行会报错
java -Dloader.path=/java/jar/lib -jar ems-0.0.1-SNAPSHOT.jar
下次在打jar包时把pom文件的第一个plugin注解掉就不会在生成lib目录