Warning: The magic method InvisibleReCaptcha\MchLib\Plugin\MchBasePublicPlugin::__wakeup() must have public visibility in /home/c9138697/public_html/juncleit.com/wp-content/plugins/invisible-recaptcha/includes/plugin/MchBasePublicPlugin.php on line 37
mvn packageとspring-boot:repackageの違いを確認してみた。 | マサトッシュブログ

Spring Boot Tips : spring-boot:repackageとmvn packageの違い

Java

「spring-boot:run」にはパッケージを作成するゴールが含まれていない。パッケージを作成するためのゴールには以下の2つの方法がある。

  • mavenのデフォルトゴールである「package」
  • Spring Bootプラグインの「spring-boot:repackage」

この2つのゴールには違いがあり、生成されるjar/warファイルに含まれるものが異なる。その違いを確認してみた。

今回は以下のサイトを参考に確認してみた。

Just a moment...

対象とするサンプルWebアプリ

今回2つのゴールの違いを確認するためのJavaソースプログラムとpom.xmlファイルは以下の通り。

package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@SpringBootApplication
public class MyApplication {

    @GetMapping("/")
    String home() {
        return "Hello, World!";
    }

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}

<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="<http://maven.apache.org/POM/4.0.0>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
    xsi:schemaLocation="<http://maven.apache.org/POM/4.0.0> <https://maven.apache.org/POM/maven-4.0.0.xsd>">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>myproject</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.2.2</version>
    </parent>

    <!-- Additional lines to be added here... -->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
</project>

上記の通り、@RestControllerを付与したControllerクラスを作成し、URLパス”/”を受信した場合のリクエストハンドラーメソッドを定義している。

このプロジェクトで”mvn spring-boot:run”を実行すると以下の処理が実行される。

  • targetディレクトリが作成される
  • Javaプログラムがコンパイルされてtargetディレクトリにclassファイルが生成される
  • springアプリケーションが実行される。
  • tomcatがロードされ、targetディレクトリをベースとしたWEBアプリが実行される
$ mvn spring-boot:run
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.example:myproject >------------------------
[INFO] Building myproject 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] >>> spring-boot:3.2.1:run (default-cli) > test-compile @ myproject >>>
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ myproject ---
[INFO] skip non existing resourceDirectory /Users/sato/proj/learn/java/spring/getstartedapp/src/main/resources
[INFO] skip non existing resourceDirectory /Users/sato/proj/learn/java/spring/getstartedapp/src/main/resources
[INFO] 
[INFO] --- compiler:3.11.0:compile (default-compile) @ myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ myproject ---
[INFO] skip non existing resourceDirectory /Users/sato/proj/learn/java/spring/getstartedapp/src/test/resources
[INFO] 
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ myproject ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< spring-boot:3.2.1:run (default-cli) < test-compile @ myproject <<<
[INFO] 
[INFO] 
[INFO] --- spring-boot:3.2.1:run (default-cli) @ myproject ---
[INFO] Attaching agents: []

  .   ____          _            __ _ _
 /\\\\ / ___'_ __ _ _(_)_ __  __ _ \\ \\ \\ \\
( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\
 \\\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.1)

2024-01-25T22:51:51.815+09:00  INFO 6743 --- [           main] com.example.MyApplication                : Starting MyApplication using Java 21.0.1 with PID 6743 (/Users/sato/proj/learn/java/spring/getstartedapp/target/classes started by sato in /Users/sato/proj/learn/java/spring/getstartedapp)
2024-01-25T22:51:51.818+09:00  INFO 6743 --- [           main] com.example.MyApplication                : No active profile set, falling back to 1 default profile: "default"
2024-01-25T22:51:52.657+09:00  INFO 6743 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2024-01-25T22:51:52.674+09:00  INFO 6743 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2024-01-25T22:51:52.674+09:00  INFO 6743 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.17]
2024-01-25T22:51:52.776+09:00  INFO 6743 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2024-01-25T22:51:52.777+09:00  INFO 6743 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 909 ms
2024-01-25T22:51:53.117+09:00  INFO 6743 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path ''
2024-01-25T22:51:53.124+09:00  INFO 6743 --- [           main] com.example.MyApplication                : Started MyApplication in 1.673 seconds (process running for 2.006)

上記処理の中にはjarファイルもしくはwarファイルの作成は含まれていない。”spring-boot:run”はコンパイルしたプログラムをローカルで実行するためのゴールになっているので、作成したプログラムを別プログラムから参照したり、クラウドにデプロイするためにjarファイルやwarファイルにする場合は”package”ゴールもしくは”spring-boot:repackage”ゴールを指定する必要がある。

mavenのpackageゴール

mavenの”package”ゴールを実行すると、ビルド対象のプロジェクト配下に存在するソースコードをコンパイルしてclassファイルを生成し、リソースファイルと共にjarもしくはwarファイルを作成する。

packageで作成したjarファイルの内容

実行して作成したjarファイルの内容を見てみた。

$ jar -tvf myproject-0.0.1-SNAPSHOT.jar
     0 Thu Jan 25 22:42:26 JST 2024 META-INF/
   154 Thu Jan 25 22:42:26 JST 2024 META-INF/MANIFEST.MF
     0 Tue Jan 23 21:01:32 JST 2024 com/
     0 Tue Jan 23 21:01:32 JST 2024 com/example/
     0 Thu Jan 25 22:42:26 JST 2024 META-INF/maven/
     0 Thu Jan 25 22:42:26 JST 2024 META-INF/maven/com.example/
     0 Thu Jan 25 22:42:26 JST 2024 META-INF/maven/com.example/myproject/
   975 Tue Jan 23 21:01:32 JST 2024 com/example/MyApplication.class
   835 Sun Jan 14 17:49:42 JST 2024 META-INF/maven/com.example/myproject/pom.xml
    64 Tue Jan 23 17:35:20 JST 2024 META-INF/maven/com.example/myproject/pom.properties

ここで生成されたjarファイルを使ってローカルでWEBアプリを実行しようとすると、実行できない。

$ java -jar ./target/myproject-0.0.1-SNAPSHOT.jar
./target/myproject-0.0.1-SNAPSHOT.jarにメイン・マニフェスト属性がありません

マニフェストファイルを見てみると、当然メインクラスが指定されていないため、Javaランタイムはエントリーポイントが分からずエラーになった。

Manifest-Version: 1.0
Created-By: Maven JAR Plugin 3.3.0
Build-Jdk-Spec: 21
Implementation-Title: myproject
Implementation-Version: 0.0.1-SNAPSHOT

また、当然のことながら生成したjarにはWEBアプリに必要となるサーブレットコンテナーや依存関係のあるクラスが含まれていないため、クラスパスもしくはjarファイルとして別途サーブレットコンテナーや依存関係のあるクラスを指定する必要がある。

ここで分かることは、mavenの”package”ゴールは、ターゲットとなったソースコードをjarもしくはwarにアーカイブするだけで、実行するために必要なライブラリやメインクラスの指定が含まれないため”java -jar xxx.jar”の形式では実行できない。

Spring Bootのrepackageの説明

Spring Boot Maven Plugin Documentation

上記のリンク先にある説明は非常に分かりづらいのだが、要するに作成したjarファイルを元に、MANIFEST.MFを書き換えてメインクラスを指定し、かつ実行するために必要となるすべてのjarファイルを含めた”fat jar”を作成するというゴールであるということ。

だが、この「repackage」という名前、なぜ「再パッケージ」なのか最初は疑問だった。

repackageは単独実行ではエラーとなる

実際に実行すると、「ソースファイルの指定が必須」的なエラーになり、「なんか使い方がよくわからない」という感じだった。

$ mvn spring-boot:repackage
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.example:myproject >------------------------
[INFO] Building myproject 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- spring-boot:3.2.1:repackage (default-cli) @ myproject ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.242 s
[INFO] Finished at: 2024-01-25T22:31:55+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.2.1:repackage (default-cli) on project myproject: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:3.2.1:repackage failed: Source file must not be null -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] <http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException>

(エラーの理解が雑なのだが、ここに時間をかけていられないので、このエラーは一旦「spring-boot:repackageを単独で実行すると上記エラーとなる」ということだけメモっておく)

repackageの実行方法

以下のサイトの情報を元にrepackageというゴールを実行できたことでこの名の理由がわかった。

spring-boot:repackageを実行するためにはpackageの後に指定する必要がある。

情報は古いが、このビルド方法はこのログを書いている時点(2024/1/28)で有効だ。

$ mvn package spring-boot:repackage
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------------< com.example:myproject >------------------------
[INFO] Building myproject 0.0.1-SNAPSHOT
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ myproject ---
[INFO] skip non existing resourceDirectory /Users/sato/proj/learn/java/spring/diffMvnPackageAndSpringBootRepackage/src/main/resources
[INFO] skip non existing resourceDirectory /Users/sato/proj/learn/java/spring/diffMvnPackageAndSpringBootRepackage/src/main/resources
[INFO] 
[INFO] --- compiler:3.11.0:compile (default-compile) @ myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- resources:3.3.1:testResources (default-testResources) @ myproject ---
[INFO] skip non existing resourceDirectory /Users/sato/proj/learn/java/spring/diffMvnPackageAndSpringBootRepackage/src/test/resources
[INFO] 
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ myproject ---
[INFO] No sources to compile
[INFO] 
[INFO] --- surefire:3.1.2:test (default-test) @ myproject ---
[INFO] No tests to run.
[INFO] 
[INFO] --- jar:3.3.0:jar (default-jar) @ myproject ---
[INFO] 
[INFO] --- spring-boot:3.2.2:repackage (default-cli) @ myproject ---
Downloading from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-buildpack-platform/3.2.2/spring-boot-buildpack-platform-3.2.2.pom>
Downloaded from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-buildpack-platform/3.2.2/spring-boot-buildpack-platform-3.2.2.pom> (3.2 kB at 11 kB/s)
Downloading from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/3.2.2/spring-boot-loader-tools-3.2.2.pom>
Downloaded from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/3.2.2/spring-boot-loader-tools-3.2.2.pom> (2.2 kB at 140 kB/s)
Downloading from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-buildpack-platform/3.2.2/spring-boot-buildpack-platform-3.2.2.jar>
Downloading from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/3.2.2/spring-boot-loader-tools-3.2.2.jar>
Downloaded from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-buildpack-platform/3.2.2/spring-boot-buildpack-platform-3.2.2.jar> (272 kB at 3.4 MB/s)
Downloaded from central: <https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/3.2.2/spring-boot-loader-tools-3.2.2.jar> (434 kB at 4.2 MB/s)
[INFO] Replacing main artifact /Users/sato/proj/learn/java/spring/diffMvnPackageAndSpringBootRepackage/target/myproject-0.0.1-SNAPSHOT.jar with repackaged archive, adding nested dependencies in BOOT-INF/.
[INFO] The original artifact has been renamed to /Users/sato/proj/learn/java/spring/diffMvnPackageAndSpringBootRepackage/target/myproject-0.0.1-SNAPSHOT.jar.original
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.553 s
[INFO] Finished at: 2024-01-28T18:41:48+09:00
[INFO] ------------------------------------------------------------------------

packageゴールでjarを作成し、その後にrepackageゴールにてjarファイルを再作成している。

repackage後のjarファイルの内容

再作成したjarファイルの内容を確認してみると、spring-boot関連のクラスが追加され、サードパーティjarファイルが複数含まれており、かつMANIFEST.MFファイルにもmain-classが指定されている。

$ jar xvf myproject-0.0.1-SNAPSHOT.jar
  META-INF/が作成されました
 META-INF/MANIFEST.MFが展開されました
  META-INF/services/が作成されました
 META-INF/services/java.nio.file.spi.FileSystemProviderが展開されました
  org/が作成されました
  org/springframework/が作成されました
  org/springframework/boot/が作成されました
  org/springframework/boot/loader/が作成されました
  org/springframework/boot/loader/jar/が作成されました
 org/springframework/boot/loader/jar/ManifestInfo.classが展開されました
 org/springframework/boot/loader/jar/MetaInfVersionsInfo.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFile$JarEntriesEnumeration.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFile$JarEntryInflaterInputStream.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFile$JarEntryInputStream.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFile$NestedJarEntry.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFile$RawZipDataInputStream.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFile$ZipContentEntriesSpliterator.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFile.classが展開されました
 org/springframework/boot/loader/jar/NestedJarFileResources.classが展開されました
 org/springframework/boot/loader/jar/SecurityInfo.classが展開されました
 org/springframework/boot/loader/jar/ZipInflaterInputStream.classが展開されました
  org/springframework/boot/loader/jarmode/が作成されました
 org/springframework/boot/loader/jarmode/JarMode.classが展開されました
  org/springframework/boot/loader/launch/が作成されました
 org/springframework/boot/loader/launch/Archive$Entry.classが展開されました
 org/springframework/boot/loader/launch/Archive.classが展開されました
 org/springframework/boot/loader/launch/ClassPathIndexFile.classが展開されました
 org/springframework/boot/loader/launch/ExecutableArchiveLauncher.classが展開されました
 org/springframework/boot/loader/launch/ExplodedArchive$FileArchiveEntry.classが展開されました
 org/springframework/boot/loader/launch/ExplodedArchive.classが展開されました
 org/springframework/boot/loader/launch/JarFileArchive$JarArchiveEntry.classが展開されました
 org/springframework/boot/loader/launch/JarFileArchive.classが展開されました
 org/springframework/boot/loader/launch/JarLauncher.classが展開されました
 org/springframework/boot/loader/launch/JarModeRunner.classが展開されました
 org/springframework/boot/loader/launch/LaunchedClassLoader$DefinePackageCallType.classが展開されました
 org/springframework/boot/loader/launch/LaunchedClassLoader.classが展開されました
 org/springframework/boot/loader/launch/Launcher.classが展開されました
 org/springframework/boot/loader/launch/PropertiesLauncher$Instantiator$Using.classが展開されました
 org/springframework/boot/loader/launch/PropertiesLauncher$Instantiator.classが展開されました
 org/springframework/boot/loader/launch/PropertiesLauncher.classが展開されました
 org/springframework/boot/loader/launch/SystemPropertyUtils.classが展開されました
 org/springframework/boot/loader/launch/WarLauncher.classが展開されました
  org/springframework/boot/loader/log/が作成されました
 org/springframework/boot/loader/log/DebugLogger$DisabledDebugLogger.classが展開されました
 org/springframework/boot/loader/log/DebugLogger$SystemErrDebugLogger.classが展開されました
 org/springframework/boot/loader/log/DebugLogger.classが展開されました
  org/springframework/boot/loader/net/が作成されました
  org/springframework/boot/loader/net/protocol/が作成されました
 org/springframework/boot/loader/net/protocol/Handlers.classが展開されました
  org/springframework/boot/loader/net/protocol/jar/が作成されました
 org/springframework/boot/loader/net/protocol/jar/Canonicalizer.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/Handler.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/JarFileUrlKey.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/JarUrl.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/JarUrlClassLoader$OptimizedEnumeration.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/JarUrlClassLoader.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/JarUrlConnection$ConnectionInputStream.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/JarUrlConnection$EmptyUrlStreamHandler.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/JarUrlConnection.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/LazyDelegatingInputStream.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/Optimizations.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlJarEntry.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlJarFile.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlJarFileFactory.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlJarFiles$Cache.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlJarFiles.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlJarManifest$ManifestSupplier.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlJarManifest.classが展開されました
 org/springframework/boot/loader/net/protocol/jar/UrlNestedJarFile.classが展開されました
  org/springframework/boot/loader/net/protocol/nested/が作成されました
 org/springframework/boot/loader/net/protocol/nested/Handler.classが展開されました
 org/springframework/boot/loader/net/protocol/nested/NestedLocation.classが展開されました
 org/springframework/boot/loader/net/protocol/nested/NestedUrlConnection$ConnectionInputStream.classが展開されました
 org/springframework/boot/loader/net/protocol/nested/NestedUrlConnection.classが展開されました
 org/springframework/boot/loader/net/protocol/nested/NestedUrlConnectionResources.classが展開されました
  org/springframework/boot/loader/net/util/が作成されました
 org/springframework/boot/loader/net/util/UrlDecoder.classが展開されました
  org/springframework/boot/loader/nio/が作成されました
  org/springframework/boot/loader/nio/file/が作成されました
 org/springframework/boot/loader/nio/file/NestedByteChannel$Resources.classが展開されました
 org/springframework/boot/loader/nio/file/NestedByteChannel.classが展開されました
 org/springframework/boot/loader/nio/file/NestedFileStore.classが展開されました
 org/springframework/boot/loader/nio/file/NestedFileSystem.classが展開されました
 org/springframework/boot/loader/nio/file/NestedFileSystemProvider.classが展開されました
 org/springframework/boot/loader/nio/file/NestedPath.classが展開されました
  org/springframework/boot/loader/ref/が作成されました
 org/springframework/boot/loader/ref/Cleaner.classが展開されました
 org/springframework/boot/loader/ref/DefaultCleaner.classが展開されました
  org/springframework/boot/loader/zip/が作成されました
 org/springframework/boot/loader/zip/ByteArrayDataBlock.classが展開されました
 org/springframework/boot/loader/zip/CloseableDataBlock.classが展開されました
 org/springframework/boot/loader/zip/DataBlock.classが展開されました
 org/springframework/boot/loader/zip/DataBlockInputStream.classが展開されました
 org/springframework/boot/loader/zip/FileChannelDataBlock$ManagedFileChannel.classが展開されました
 org/springframework/boot/loader/zip/FileChannelDataBlock$Tracker.classが展開されました
 org/springframework/boot/loader/zip/FileChannelDataBlock.classが展開されました
 org/springframework/boot/loader/zip/NameOffsetLookups.classが展開されました
 org/springframework/boot/loader/zip/VirtualDataBlock.classが展開されました
 org/springframework/boot/loader/zip/VirtualZipDataBlock$DataPart.classが展開されました
 org/springframework/boot/loader/zip/VirtualZipDataBlock.classが展開されました
 org/springframework/boot/loader/zip/Zip64EndOfCentralDirectoryLocator.classが展開されました
 org/springframework/boot/loader/zip/Zip64EndOfCentralDirectoryRecord.classが展開されました
 org/springframework/boot/loader/zip/ZipCentralDirectoryFileHeaderRecord.classが展開されました
 org/springframework/boot/loader/zip/ZipContent$Entry.classが展開されました
 org/springframework/boot/loader/zip/ZipContent$Kind.classが展開されました
 org/springframework/boot/loader/zip/ZipContent$Loader.classが展開されました
 org/springframework/boot/loader/zip/ZipContent$Source.classが展開されました
 org/springframework/boot/loader/zip/ZipContent.classが展開されました
 org/springframework/boot/loader/zip/ZipDataDescriptorRecord.classが展開されました
 org/springframework/boot/loader/zip/ZipEndOfCentralDirectoryRecord$Located.classが展開されました
 org/springframework/boot/loader/zip/ZipEndOfCentralDirectoryRecord.classが展開されました
 org/springframework/boot/loader/zip/ZipLocalFileHeaderRecord.classが展開されました
 org/springframework/boot/loader/zip/ZipString$CompareType.classが展開されました
 org/springframework/boot/loader/zip/ZipString.classが展開されました
  BOOT-INF/が作成されました
  BOOT-INF/classes/が作成されました
  BOOT-INF/classes/com/が作成されました
  BOOT-INF/classes/com/example/が作成されました
  META-INF/maven/が作成されました
  META-INF/maven/com.example/が作成されました
  META-INF/maven/com.example/myproject/が作成されました
 BOOT-INF/classes/com/example/MyProject.classが展開されました
 META-INF/maven/com.example/myproject/pom.xmlが展開されました
 META-INF/maven/com.example/myproject/pom.propertiesが展開されました
  BOOT-INF/lib/が作成されました
BOOT-INF/lib/spring-boot-3.2.2.jarが抽出されました
BOOT-INF/lib/spring-boot-autoconfigure-3.2.2.jarが抽出されました
BOOT-INF/lib/logback-classic-1.4.14.jarが抽出されました
BOOT-INF/lib/logback-core-1.4.14.jarが抽出されました
BOOT-INF/lib/slf4j-api-2.0.11.jarが抽出されました
BOOT-INF/lib/log4j-to-slf4j-2.21.1.jarが抽出されました
BOOT-INF/lib/log4j-api-2.21.1.jarが抽出されました
BOOT-INF/lib/jul-to-slf4j-2.0.11.jarが抽出されました
BOOT-INF/lib/jakarta.annotation-api-2.1.1.jarが抽出されました
BOOT-INF/lib/spring-core-6.1.3.jarが抽出されました
BOOT-INF/lib/spring-jcl-6.1.3.jarが抽出されました
BOOT-INF/lib/snakeyaml-2.2.jarが抽出されました
BOOT-INF/lib/jackson-databind-2.15.3.jarが抽出されました
BOOT-INF/lib/jackson-annotations-2.15.3.jarが抽出されました
BOOT-INF/lib/jackson-core-2.15.3.jarが抽出されました
BOOT-INF/lib/jackson-datatype-jdk8-2.15.3.jarが抽出されました
BOOT-INF/lib/jackson-datatype-jsr310-2.15.3.jarが抽出されました
BOOT-INF/lib/jackson-module-parameter-names-2.15.3.jarが抽出されました
BOOT-INF/lib/tomcat-embed-core-10.1.18.jarが抽出されました
BOOT-INF/lib/tomcat-embed-el-10.1.18.jarが抽出されました
BOOT-INF/lib/tomcat-embed-websocket-10.1.18.jarが抽出されました
BOOT-INF/lib/spring-web-6.1.3.jarが抽出されました
BOOT-INF/lib/spring-beans-6.1.3.jarが抽出されました
BOOT-INF/lib/micrometer-observation-1.12.2.jarが抽出されました
BOOT-INF/lib/micrometer-commons-1.12.2.jarが抽出されました
BOOT-INF/lib/spring-webmvc-6.1.3.jarが抽出されました
BOOT-INF/lib/spring-aop-6.1.3.jarが抽出されました
BOOT-INF/lib/spring-context-6.1.3.jarが抽出されました
BOOT-INF/lib/spring-expression-6.1.3.jarが抽出されました
BOOT-INF/lib/spring-boot-jarmode-layertools-3.2.2.jarが抽出されました
 BOOT-INF/classpath.idxが展開されました
 BOOT-INF/layers.idxが展開されました

大きくは以下のように変わっていた。

  • ”BOOT-INF/classes”ディレクトリが追加され、プロジェクトクラスはここに移動されている。
  • “BOOT-INF/lib”ディレクトリが追加され、サードパーティjarが保存されている。
  • “org/springframework”ディレクトリが追加され、Spring Bootの起動用クラスが保存されている。
  • MANIFEST.MFファイルにSpring Boot関連の定義が追加されている。

ようやく”repackage”という名前の意味がわかった。

また、”repackage”は、単独では動作せず、必ずpackageにてjarを作成してから実行するものであるということもわかった。

毎回”mvn package spring-boot:repackage”を実行するのも面倒ということで、それを簡易化するためにも利用できるspring boot のmaven pluginを次回確認する。

コメント

タイトルとURLをコピーしました