You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// network_container - if the generated Docker container needs to run on the same network as an external dependency, this is the name of that container dependency
134
+
// custom_hint_include_file - if the native compilation section needs additional description in the form of a custom hint, this is the file that should be rendered as additional content
:native_image_run_command: docker run docker.io/library/{build_name}:{build_version}
152
+
153
+
154
+
155
+
== Building the Application
156
+
157
+
In this section, we will describe four different ways to run this guide:
158
+
159
+
1. https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.build-systems[Building and executing a JAR file]
160
+
2. https://docs.spring.io/spring-boot/docs/current/reference/html/container-images.html#container-images.buildpacks[Building and executing a Docker container, using Cloud Native Buildpacks^]
161
+
3. https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.developing-your-first-application.native-build-tools[Building and executing a native image^]
162
+
4. https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.developing-your-first-application.buildpacks[Building and executing a native image container, using Cloud Native Buildpacks^]
163
+
164
+
Regardless of how you choose to execute the application, the output should be the same.
165
+
166
+
To run the application, you can package the application as an executable jar.
167
+
The command `{jar_build_command}` will compile the application to an executable jar.
168
+
You can then run the jar with the command `{jar_run_command}`
169
+
170
+
Alternatively, if you have a Docker environment available, you could create a Docker image directly from your Maven or Gradle plugin, using buildpacks.
171
+
With https://docs.spring.io/spring-boot/docs/current/reference/html/container-images.html#container-images.buildpacks[Cloud Native Buildpacks^], you can create Docker compatible images that you can run anywhere.
172
+
Spring Boot includes buildpack support directly for both Maven and Gradle.
173
+
This means you can type a single command and quickly get a sensible image into a locally running Docker daemon.
174
+
To create a Docker image using Cloud Native Buildpacks, run the command `{image_build_command}`.
175
+
With a Docker environment enabled, you can execute the application with the command `{image_run_command}`
176
+
177
+
178
+
=== Native Image Support
179
+
180
+
Spring Boot also supports https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.introducing-graalvm-native-images[compilation to a native image^], provided you have a GraalVM distribution on your machine.
181
+
To create a https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.developing-your-first-application.native-build-tools.gradle[native image with Gradle^] using Native Build Tools, first make sure that your Gradle build contains a `plugins` block that includes `org.graalvm.buildtools.native`.
182
+
----
183
+
plugins {
184
+
id 'org.graalvm.buildtools.native' version '0.9.28'
185
+
...
186
+
----
187
+
188
+
189
+
You can run the command `{native_build_command}` to generate a native image. When the build completes, you will be able to run the code with a near instantaneous start up time by executing the command `{native_run_command}`.
190
+
191
+
192
+
You can also create a https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html#native-image.developing-your-first-application.buildpacks[Native Image using Buildpacks^]. You can generate a native image by running the command `{native_image_build_command}`. Once the build completes, you can start your application with the command `{native_image_run_command}`
193
+
194
+
128
195
129
196
== Summary
130
197
@@ -137,4 +204,7 @@ The following guides may also be helpful:
137
204
* https://spring.io/guides/gs/spring-boot/[Building an Application with Spring Boot^]
138
205
* https://spring.io/guides/gs/batch-processing/[Creating a Batch Service^]
Want to write a new guide or contribute to an existing one? Check out our https://github.com/spring-guides/getting-started-guides/wiki[contribution guidelines].
209
+
210
+
IMPORTANT: All guides are released with an ASLv2 license for the code, and an http://creativecommons.org/licenses/by-nd/3.0/[Attribution, NoDerivatives creative commons license] for the writing.
0 commit comments