问题1:springboot构建jar部署,maven构建的jar包含 \BOOT-INF\lib\下的所有依赖jar包,jar包文件太大。
解决:
1.pom文件 加配置
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.johnnian.App</mainClass>
<layout>ZIP</layout>
<includes>
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
2.打包
maven install之后,将jar包用360打开,将jar包中BOOT-INF里面的lib拷出来,然后将jar包的lib删掉
启动:java -Dloader.path=lib/ -jar xxx.jar
问题2:普通打包 maven install jar包 java -jar 跑不起来,缺少依赖包
普通打包:将依赖包放入项目lib中添加的pom(亲测成功)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
/*<layout>ZIP</layout>
<includes>
<include>
<groupId>nothing</groupId>
<artifactId>nothing</artifactId>
</include>
</includes>*/ 如果有这一段 注掉
解析:
a.第一种打包:jar包和依赖包分离打包(只有代码)
b.第二种打包:jar包包含依赖包(有代码和依赖包)