SpringBoot/SpringCloud maven分离打包
程序员文章站
2024-03-22 18:59:58
...
SpringBoot/SpringCloud maven分离打包
目的:把微服务的jar包尽量变得足够小,公共不变jar包进行提取放到特定文件夹内,然后启动jar包的时候进行指定lib文件目录地址即可。
以下是我的maven配置:
<build>
<plugins>
<plugin>
<!--打包时去除第三方依赖-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<!--此处可以指定包含jar包-->
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</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>D:/workspace/demo-service/target/lib</outputDirectory>
<!--<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>compile</includeScope>-->
</configuration>
</execution>
</executions>
<configuration>
<!-- 本地Jar包不进行分离,不输出到outputDirectory -->
<excludeGroupIds>com.demo.service</excludeGroupIds>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
- 启动命令:
java -jar -Dloader.path=D:/workspace/demo-service/target/lib demo-service-demo1.jar
推荐阅读
-
SpringBoot/SpringCloud maven分离打包
-
Maven 打包实现生产环境与测试环境配置分离
-
SpringBoot打包报错:Missing POM for org.apache.maven.surefire:surefire-junit3:jar
-
IDEA打包Springboot+maven项目
-
通过Maven将Springboot项目打包为jar并发布
-
maven+springboot项目使用idea打包
-
springboot项目maven打包:程序包com.sun.image.codec.jpeg不存在
-
使用Maven为SpringBoot项目打包
-
SpringBoot项目利用maven自定义打包结构
-
springboot项目利用maven进行多环境打包