私は私の春のブートアプリケーションを構築したいが、私は別のサーバーに多くのファイルを転送する必要があります。しかし、私の "jar"ファイル内の "libs"フォルダは、今は大きすぎます。それは100MB ++です。私の巨大な100MBのjarファイルを圧縮する(春のブートメイヴンプラグイン)
私が望むのは、webappを1MBなどのように定期的に更新し、100MBの "libs"フォルダのコピーを別のサーバの出力ディレクトリに保存することです。ほとんどの場合、libsの更新はほとんどありません。
次のPOMファイルは100MBのJARを作成し、100MBの "libs"フォルダを作成します。次に、2つを一緒にジップします。しかし、私は100MBJARをもっと小さくする方法は分かりません(コンパイルするには、springbootライブラリが最も重要です)。私は<include>
タグか何かが必要だと思う。
しかし、それは唯一の組み込みSpringBoot &のTomcatから最も重要なファイルが含まれていますが、別のフォルダに外の他のライブラリのほとんどを保つように、私はのconfigure「春のブートMavenプラグイン」への正しい方法を発見していません。
春・ブートのmaven-pluginのとgroupIDsのカンマ区切りリストへのpom.xml
<build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<excludes>
<exclude>node_modules/**</exclude>
<exclude>bower_components/**</exclude>
<exclude>node/**</exclude>
</excludes>
</resource>
<resource>
<directory>${project.build.directory}/generated-resources</directory>
</resource>
</resources>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<projectNameTemplate>[groupId].[artifactId]</projectNameTemplate>
</configuration>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}.lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>${project.build.finalName}.lib/</classpathPrefix>
<mainClass>${fully.qualified.main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>antrun-archive</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="final.name" value="${project.build.directory}/${project.build.finalName}"/>
<property name="archive.includes" value="${project.build.finalName}.${project.packaging} ${project.build.finalName}.lib/*"/>
<property name="tar.destfile" value="${final.name}.tar"/>
<!-- <zip basedir="${project.build.directory}" destfile="${final.name}.zip" includes="${archive.includes}" /> -->
<tar basedir="${project.build.directory}" destfile="${tar.destfile}" includes="${archive.includes}" />
<gzip src="${tar.destfile}" destfile="${tar.destfile}.gz" />
<!-- <bzip2 src="${tar.destfile}" destfile="${tar.destfile}.bz2" /> -->
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
を参照してください。https://github.com/dsyer/spring-boot-thin-launcher –
「rsync」の使用やバイナリデルタファイルの作成を検討したいと思います。 Spring Boot - 自己完結型のJARファイルを1つ持つ。もう1つのオプションは、Spring MVCアプリケーションでスタンドアロンのTomcatサーバーを使用し、いくつかの依存関係をMavenにJARファイルに含めないように 'ランタイム'としてマークすることです。 –