打包插件去除jar包瘦身 使用springboot

使用springboot,打包插件去除jar包瘦身,博智网带你了解详细信息 。
1、pom文件配置1.1 添加maven-dependency-plugin插件用于将引用的jar包拷贝到指定的路径便于后续tomcat启动指定依赖包路径
<!--拷贝依赖到jar外面的lib目录--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><executions><execution><id>copy</id><phase>package</phase><goals><goal>copy-dependencies</goal></goals><configuration><!--指定的依赖路径--><outputDirectory>${project.build.directory}/lib</outputDirectory></configuration></execution></executions></plugin>
使用这个插件构建完之后的目录结构多了一个lib目录(即上述配置的outputDirectory指定的路径),里面是依赖的jar包:

打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
打包插件去除jar包瘦身 使用springboot

文章插图
这个可以自定义执行主入口类,有以下几种方式:1.POM继承spring-boot-starter-parent<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.9.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><!-- The main class to start by executing java -jar --><start-class>ccom.notes.JavaNotesApplication</start-class></properties>
2.POM不是继承spring-boot-starter-parent时需指定<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.1.9.RELEASE</version><configuration><mainClass>com.notes.JavaNotesApplication</mainClass><layout>ZIP</layout></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin>
3.POM不是继承spring-boot-starter-paren,且使用maven-jar-plugin插件来指定执行的类<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><configuration><archive><manifest><addClasspath>true</addClasspath><useUniqueVersions>false</useUniqueVersions><classpathPrefix>lib/</classpathPrefix><mainClass>com.notes.JavaNotesApplication</mainClass></manifest><manifestEntries><version>${project.version}</version></manifestEntries></archive></configuration></plugin>
【打包插件去除jar包瘦身 使用springboot】以上为个人经验,希望能给大家一个参考,也希望大家多多支持趣讯吧 。