What is a Spring Boot .original file?

When you create a Spring Boot project and execute the mvn clean package command, the .original file is created in the target directory as shown below.

image.png

I tried to find out what this was.

The .original file is just a Jar or War

Yes, it's just a Jar file, a War file.

Spring Boot can create an Executable Jar (War). This format is for Jar and War that are not .original.

.original is not an Executable, it's just a Jar or War.

As you can see by unzipping the Jar and War and comparing the contents, the Executive Jar (War) contains the Spring Boot related classes required for execution, and the directory structure is different.

Details are explained in the official documentation. https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html

Made by Spring Boot Maven Plugin

This file is created by Spring Boot Maven Plugin. This Plugin has a goal of spring-boot: repackage, where we create an Executable Jar (War) and rename the Jar and War originally packaged in Maven to the name .original.

The reason why it is created even though spring-boot: repackage is not specified like mvn clean package is that the following settings are set in pom.xml of spring-boot-starter-parent. Is being done.

pom.xml(Excerpt)


<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>repackage</id>
      <goals>
        <goal>repackage</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <mainClass>${start-class}</mainClass>
  </configuration>
</plugin>

repackage is executed in the package phase, so if you do mvn clean package, repackage will also be executed.

To avoid creating a .original file

If you need to create an Executable Jar (War), the .original file will always be created. However, if you just want to create a Jar or War, you can skip creating an Executable Jar (War) with one of the following:

mvn clean package -Dspring-boot.repackage.skip=true

pom.xml


<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
  </plugins>
</build>

How to use the .original file

If the operation is to deploy the War file to the application server without using the embedded Tomcat, it does not need to be an Executable War. (Of course, you can also deploy in Executable War.)

Executable War also includes the Spring Boot classes needed to run it, as well as Maven-provided scoped libraries, so it tends to be larger than a regular War file. Therefore, if you are doing this kind of operation, you can reduce the file size by deploying the .original file or making the above settings so that Executable War is not created. I will.

However, I think the good thing about Spring Boot is that it can be executed quickly with the java command.

Recommended Posts

What is a Spring Boot .original file?
What is a jar file?
What is @Autowired in Spring boot?
What is a constructor?
What is a stream
What is Spring Tools 4
What is a Servlet?
What is a wrapper class?
What is a boolean type?
What is a Ruby module?
What is a floating point?
What is a meaningful comment?
File upload with Spring Boot
What is a Java collection?
What is a lambda expression?
What is a fa⁉ enum?
Error handling when the maximum file size is exceeded when uploading a file with Spring Boot
What is a snippet in programming?
What is a column Boolean type?
What is a reference type variable?
What is a lambda expression (Java)
A memo that touched Spring Boot
[Swift] What is "inheriting a class"?
What is a Ruby 2D array?
RSocket is supported in Spring Boot 2.2, so give it a try
Fitted in Spring Boot using a bean definition file named application.xml
What is a class in Java language (3 /?)
What is a terminal? -Absolute path & relative path-
Static file access priority in Spring boot
[For programming beginners] What is a method?
Local file download memorandum in Spring Boot
What is the best file reading (Java)
What is a class in Java language (1 /?)
What is a class in Java language (2 /?)
[Rails] What is a dot (.) Or a colon (:)?
What is a request scope? Image commentary
How to split Spring Boot message file
Create a website with Spring Boot + Gradle (jdk1.8.x)
What is Docker?
What to do when you want to delete a migration file that is "NO FILE"
What is null? ]
Summary of what I learned about Spring Boot
Create a simple search app with Spring Boot
What is java
Introduction to Recursive Functions: What is a Recursive Function?
What is Keycloak
Run a Spring Boot project in VS Code
What is maven?
What is Jackson?
Spring MVC: What happens when `@ RequestParam` is omitted
What is Docker
What is self
What is Jenkins
What is ArgumentMatcher?
What is IM-Juggling?
Create a Spring Boot application using IntelliJ IDEA
Challenge Spring Boot
What is params
What is SLF4J?
How to add a classpath in Spring Boot
What is Facade? ??