1. 使用插件配置
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <configuration>
- <outputDirectory>
- <--我放到父目录方便找-->
- ${project.parent.basedir}/zjar
- </outputDirectory>
- <--重要 不然在找不到main入口-->
- <layout>ZIP</layout>
- <includes>
- <!--这里是填写经常变动的jar,一般都是自己的包模块-->
- <!--如果没有取消这里的注释 non-exists-->
- <!-- <include>-->
- <!-- <groupId>non-exists</groupId>-->
- <!-- <artifactId>non-exists</artifactId>-->
- <!-- </include>-->
-
- <include>
- <groupId>com.sosocom 自己的包</groupId>
- <artifactId>ability-base</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>
- <outputDirectory>
- ${project.parent.basedir}/zjar/lib
- </outputDirectory>
- <excludeTransitive>false</excludeTransitive>
- <stripVersion>false</stripVersion>
- <includeScope>runtime</includeScope>
- <!--这里特别重要 要加上, 不然你那些频繁改动,自己的包,发现项目里并不生效-->
- <excludeGroupIds>com.sosocom</excludeGroupIds>
- </configuration>
- </execution>
- </executions>
- </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>
- <outputDirectory>
- ${project.parent.basedir}/zjar/lib
- </outputDirectory>
- <excludeTransitive>false</excludeTransitive>
- <stripVersion>false</stripVersion>
- <includeScope>runtime</includeScope>
- <!--这里特别重要 要加上, 不然你那些频繁改动,自己的包,发现项目里并不生效-->
- <excludeGroupIds>com.sosocom</excludeGroupIds>
- </configuration>
- </execution>
- </executions>
- </plugin>
执行打包, mvn clean package;
生成的lib文件夹,上传到服务器,将来就不怎么需要上传了。
服务器启动命令
使用-D 指定库
java -Dloader.path=/root/lib -jar /root/test.jar > /dev/null 2>&1 &
以后每次打包只需上传jar, 就可以了。 小了差不多100倍, 上传巨快