修改主pom文件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<!--打包时去除第三方依赖-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes> <!-- 不排除的依赖 -->
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
<include>
<groupId>com.text.aaa</groupId>
<artifactId>${project.parent.artifactId}-core</artifactId>
</include>
<include>
<groupId>com.text.aaa</groupId>
<artifactId>common</artifactId>
</include>
</includes>
</configuration>
</plugin>
<!--拷贝第三方依赖文件到指定目录-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!--target/lib是依赖jar包的输出目录,根据自己喜好配置-->
<outputDirectory>target/lib/${project.parent.artifactId}</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
<!-- 不拷贝的依赖 -->
<excludeArtifactIds>common,${project.parent.artifactId}-core</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<configuration>
<filesets>
<fileset>
<!-- 指定执行clean要操作的目录 -->
<directory>../../A-deploy/package/lib/${project.parent.artifactId}</directory>
<includes>
<!-- 目录下要删除的数据,**/*=删除目录下的文件,不删除目录,**=删除整个目录 -->
<include>**/*</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
<!-- 删除业务代码jar包 -->
<fileset>
<directory>../../A-deploy/package/jars/</directory>
<includes>
<include>${project.artifactId}.jar</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
linux 启动:nohup java -Dloader.path=lib包的路径,resources,lib -Dfile.encoding=utf-8 -jar xxx.jar &
windows:java -Dloader.path=D:\work\测试\yt_service_system_test\ruoyi-admin\target\lib\ruoyi,resources,lib -Dfile.encoding=utf-8 -jar ruoyi-admin.jar