Spring Native Documentation

2y ago
15 Views
2 Downloads
1.24 MB
58 Pages
Last View : 14d ago
Last Download : 3m ago
Upload by : Abby Duckworth
Transcription

Spring Native documentationVersion 0.11.1 - Andy Clement, Sébastien Deleuze, Filip Hanik, Dave Syer,Esteban Ginez, Jay Bryant, Brian Clozel, Stéphane Nicoll, Josh Long

Table of Contents1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1. Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12. Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1. Getting started with Buildpacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.1. System Requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.1.2. Sample Project Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Validate Spring Boot version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Add the Spring Native dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Add the Spring AOT plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5Enable native image support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Freeze GraalVM version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Maven Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.1.3. Build the native application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.1.4. Run the native application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.2. Getting started with Native Build Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.1. System Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2.2. Sample Project Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Validate Spring Boot version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Add the Spring Native dependency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11Add the Spring AOT plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Add the native build tools plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13Maven Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.2.3. Build the native application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.2.4. Run the native application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.2.5. Test the native application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173. Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.1. GraalVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.2. Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.3. Tooling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.4. Feature flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.5. Spring Boot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.5.1. Starters requiring special build configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.5.2. Starters requiring no special build configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.6. Spring Cloud. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.7. Others . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.8. Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234. Spring AOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.1. BeanFactory Preparation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

4.2. Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244.3. Additional Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255. Native hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265.1. Annotated Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265.2. Programmatic Hints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275.3. Manual Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286. Build Setup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.1. Maven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296.2. Gradle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306.3. AOT Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326.3.1. Debugging the source generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336.4. AOT Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337. Samples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358. Native image options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368.1. Options enabled by default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368.2. Useful options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368.3. Unsupported options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379. Tracing agent. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389.1. Running the application with the agent to compute configuration . . . . . . . . . . . . . . . . . . . . . . . . 389.2. Testing with the agent to compute configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389.2.1. A basic access-filter file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389.2.2. Using the access-filter file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399.2.3. Using it with maven . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3910. Executable JAR to native . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4110.1. With Buildpacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4110.2. With native-image. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4111. Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4311.1. native-image is failing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4311.1.1. DataSize was unintentionally initialized at build time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4311.1.2. WARNING: Could not register reflection metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4311.1.3. Out of memory error when building the native image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4311.1.4. Builder lifecycle 'creator' failed with status code 145 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4411.2. The built image does not run. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4411.2.1. Missing resource bundles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4411.2.2. Application failed to start when running mvn spring-boot:run . . . . . . . . . . . . . . . . . . . . . . . 4411.2.3. How can I configure programmatically Logback as a logback.xml alternative? . . . . . . . . 4411.2.4. Missing configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4511.2.5. AotProxyHint errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4511.2.6. No access hint found for import selector: XXX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4611.3. Working with Multi-Modules projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4611.4. Working with snapshots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

12. How to contribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4712.1. Designing native-friendly Spring libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4712.1.1. Use proxyBeanMethods false or method parameter injection in @Configuration classes . 4712.1.2. Use NativeDetector for native conditional code paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4712.1.3. Do classpath checks in static block/fields and configure build-time initialization. . . . . . 4812.1.4. Move reflection to build-time when possible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4812.2. Contributing new hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4812.3. Dynamic native configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5012.3.1. Implementing NativeConfiguration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5012.3.2. Taking more control via processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5012.4. Using container-based build environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5012.4.1. run-dev-container.sh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5112.4.2. Usual dev workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5112.5. Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5112.5.1. Comparing images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5213. Contact us. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Chapter 1. OverviewSpring Native provides support for compiling Spring applications to native executables using theGraalVM native-image compiler.Compared to the Java Virtual Machine, native images can enable cheaper and more sustainablehosting for many types of workloads. These include microservices, function workloads, well suitedto containers, and KubernetesUsing native image provides key advantages, such as instant startup, instant peak performance,and reduced memory consumption.There are also some drawbacks and trade-offs that the GraalVM native project expect to improve onover time. Building a native image is a heavy process that is slower than a regular application. Anative image has fewer runtime optimizations after warmup. Finally, it is less mature than the JVMwith some different behaviors.The key differences between a regular JVM and this native image platform are: A static analysis of your application from the main entry point is performed at build time. The unused parts are removed at build time. Configuration is required for reflection, resources, and dynamic proxies. Classpath is fixed at build time. No class lazy loading: everything shipped in the executables will be loaded in memory onstartup. Some code will run at build time. There are some limitations around some aspects of Java applications that are not fullysupported.The goal of this project is to incubate the support for Spring Native, an alternative to Spring JVM,and provide a native deployment option designed to be packaged in lightweight containers. Inpractice, the target is to support your Spring applications, almost unmodified, on this new platform. This is work in progress, see the list of supported features for more details.1.1. ModulesSpring Native is composed of the following modules: spring-native: runtime dependency required for running Spring Native, provides also Nativehints API. spring-native-configuration: configuration hints for Spring classes used by Spring AOT plugins,including various Spring Boot auto-configurations. spring-native-docs: reference guide, in asciidoc format. spring-native-tools: tools used for reviewing image building configuration and output.1

spring-aot: AOT transformation infrastructure common to Maven and Gradle plugins. spring-aot-test: Test-specific AOT transformation infrastructure. spring-aot-gradle-plugin: Gradle plugin that invokes AOT transformations. spring-aot-maven-plugin: Maven plugin that invokes AOT transformations. samples: contains various samples that demonstrate features usage and are used as integrationtests.2

Chapter 2. Getting Started Applications using Spring Native should be compiled with either Java 11 or Java17.There are two main ways to build a Spring Boot native application: Using Spring Boot Buildpacks support to generate a lightweight container containing a nativeexecutable. Using the GraalVM native image Maven plugin support to generate a native executable. The easiest way to start a new native Spring Boot project is to go to start.spring.io,add the "Spring Native" dependency and generate the project.2.1. Getting started with BuildpacksThis section gives you a practical overview of building a Spring Boot native application using CloudNative Buildpacks. This is a practical guide that uses the RESTful Web Service getting started guide.2.1.1. System RequirementsDocker should be installed, see Get Docker for more details. Configure it to allow non-root user ifyou are on Linux. You can run docker run hello-world (without sudo) to check the Docker daemon isreachable as expected. Check the Maven or Gradle Spring Boot plugindocumentation for more details.On MacOS, it is recommended to increase the memory allocated to Docker to at least 8GB, and potentially add more CPUs as well. See this Stackoverflow answer formore details. On Microsoft Windows, make sure to enable the Docker WSL 2backend for better performance.2.1.2. Sample Project SetupThe completed "RESTful Web Service" guide can be retrieved using the following commands:git clone https://github.com/spring-guides/gs-rest-servicecd gs-rest-service/completeValidate Spring Boot version Spring Native 0.11.1 only supports Spring Boot 2.6.2, so change the version ifnecessary.3

Maven parent groupId org.springframework.boot /groupId artifactId spring-boot-starter-parent /artifactId version 2.6.2 /version relativePath/ /parent Gradle Groovyplugins {// .id 'org.springframework.boot' version '2.6.2'}Gradle Kotlinplugins {// .id("org.springframework.boot") version "2.6.2"}Add the Spring Native nt as well as other mandatory classes required to run a Spring application as a nativeimage. You need to specify it explicitly only with Maven.Maven dependencies !-- . -- dependency groupId org.springframework.experimental /groupId artifactId spring-native /artifactId version 0.11.1 /version /dependency /dependencies Gradle Groovy// No need to add the spring-native dependency explicitly with Gradle, the Spring AOTplugin will add it automatically.4

Gradle Kotlin// No need to add the spring-native dependency explicitly with Gradle, the Spring AOTplugin will add it automatically.Add the Spring AOT pluginThe Spring AOT plugin performs ahead-of-time transformations required to improve native imagecompatibility and footprint. The transformations also apply to the JVM so this can be applied regardless.Maven build plugins !-- . -- plugin groupId org.springframework.experimental /groupId artifactId spring-aot-maven-plugin /artifactId version 0.11.1 /version executions execution id generate /id goals goal generate /goal /goals /execution /executions /plugin /plugins /build Gradle Groovyplugins {// .id 'org.springframework.experimental.aot' version '0.11.1'}Gradle Kotlinplugins {// .id("org.springframework.experimental.aot") version "0.11.1"}The plugin provides a number of options to customize the transformations, see [spring-aot-5

configuration] for more details.Enable native image supportSpring Boot’s Cloud Native Buildpacks support lets you build a container for your Spring Bootapplication. The native image buildpack can be enabled using the BP NATIVE IMAGE environmentvariable as follows: As of Spring Native 0.11, Liberica Native Image Kit (NIK) is the native-imagecompiler distribution used by default with Buildpacks.Maven plugin groupId org.springframework.boot /groupId artifactId spring-boot-maven-plugin /artifactId configuration image builder paketobuildpacks/builder:tiny /builder env BP NATIVE IMAGE true /BP NATIVE IMAGE /env /image /configuration /plugin Gradle GroovybootBuildImage {builder "paketobuildpacks/builder:tiny"environment ["BP NATIVE IMAGE" : "true"]}Gradle Kotlintasks.getByName BootBuildImage ("bootBuildImage") {builder "paketobuildpacks/builder:tiny"environment mapOf("BP NATIVE IMAGE" to "true")} 6tiny builder allows small footprint and reduced surface attack, you can also usebase (the default) or full builders to have more tools available in the image for animproved developer experience.

P NATIVE IMAGE BUILD ARGUMENTS environment variable.Freeze GraalVM versionBy default, GraalVM versions will be upgraded automatically by Buildpacks to the latest release.You can explicitly configure Spring Boot Maven or Gradle plugins with a specific version of javanative-image buildpack which will freeze GraalVM version, see related versions mapping. Forexample, if you want to force using GraalVM 21.3.0, you can configure:Maven plugin groupId org.springframework.boot /groupId artifactId spring-boot-maven-plugin /artifactId configuration !-- . -- image buildpacks buildpack gcr.io/paketo-buildpacks/java-nativeimage:7.1.0 /buildpack /buildpacks /image /configuration /plugin Gradle GroovybootBuildImage {// .buildpacks "]}Gradle Kotlintasks.getByName BootBuildImage ("bootBuildImage") {// .buildpacks :7.1.0")}Maven RepositoryConfigure your build to include the required repository for the spring-native dependency, asfollows:7

Maven repositories !-- . -- repository id spring-release /id name Spring release /name url https://repo.spring.io/release /url /repository /repositories Gradle Groovyrepositories {// .maven { url 'https://repo.spring.io/release' }}Gradle Kotlinrepositories {// .maven { url uri("https://repo.spring.io/release") }}The Spring AOT plugin also requires a dedicated plugin repository in the pom.xml file for Maven andin the in the settings.gradle(.kts) for Gradle.Maven pluginRepositories !-- . -- pluginRepository id spring-release /id name Spring release /name url https://repo.spring.io/release /url /pluginRepository /pluginRepositories Gradle GroovypluginManagement {repositories {// .maven { url 'https://repo.spring.io/release' }}}8

Gradle KotlinpluginManagement {repositories {// .maven { url uri("https://repo.spring.io/release") }}}2.1.3. Build the native applicationThe native application can be built as follows:Maven mvn spring-boot:build-imageGradle Groovy gradle bootBuildImageGradle Kotlin gradle bootBuildImage During the native compilation, you will see a lot of WARNING: Could not registerreflection metadata messages. They are expected and will be removed in a futureversion, see #502 for more details.This creates a Linux container to build the native application using the GraalVM native imagecompiler. By default, the container image is installed locally.2.1.4. Run the native applicationTo run the application, you can use docker the usual way as shown in the following example: docker run --rm -p 8080:8080 rest-service-complete:0.0.1-SNAPSHOTIf you prefer docker-compose, you can write a docker-compose.yml at the root of the project with thefollowing content:9

version: '3.1'services:rest-service:image: rest-service-complete:0.0.1-SNAPSHOTports:- "8080:8080"And then run docker-compose upThe startup time should be less than 100ms, compared to the roughly 1500ms when starting theapplication on the JVM.Now that the service is up, visit localhost:8080/greeting, where you should see:{"id":1,"content":"Hello, World!"}2.2. Getting started with Native Build ToolsThis section gives you a practical overview of building a Spring Boot native application using theGraalVM native build tools. This is a practical guide that uses the RESTful Web Service gettingstarted guide.2.2.1. System RequirementsA number of prerequisites are required before installing the GraalVM native-image compiler. Youthen need a local installation of the native image compiler.There are various distributions of the native-image compiler available, here we focus on those 2ones: GraalVM CE based on the GraalVM open-source repository and LabsJDK Bellsoft Liberica Native Image Kit (NIK) based on the GraalVM open-source repository andLiberica JDKTo install the native image compiler on MacOS or Linux, we recommend using SDKMAN: Install SDKMAN. Install a GraalVM native-image distribution, either GraalVM CE (grl suffix) or Bellsoft LibericaNIK (nik suffix), here we go with Liberica NIK Java 11 variant: sdk install java 21.3.0.r11-nik Make sure to use the newly installed JDK with sdk use java 21.3.0.r11-nik Run gu install native-image to bring in the native-image extensions to the JDK.Alternatively or if you are on Microsoft Windows, you can manually install builds from GraalVM or10

Liberica NIK. Don’t forget to set JAVA HOME / PATH appropriately if needed and to run gu installnative-image to bring in the native-image extensions.2.2.2. Sample Project SetupThe completed "RESTful Web Service" guide can be retrieved using the following commands:git clone https://github.com/spring-guides/gs-rest-servicecd gs-rest-service/completeValidate Spring Boot version Spring Native 0.11.1 only supports Spring Boot 2.6.2, so change the version ifnecessary.Maven parent groupId org.springframework.boot /groupId artifactId spring-boot-starter-parent /artifactId version 2.6.2 /version relativePath/ /parent Gradle Groovyplugins {id 'org.springframework.boot' version '2.6.2'// .}Gradle Kotlinplugins {id("org.springframework.boot") version "2.6.2"// .}Add the Spring Native nt as well as other mandatory classes required to run a Spring application as a nativeimage.11

Maven dependencies !-- . -- dependency groupId org.springframework.experimental /groupId artifactId spring-native /artifactId version 0.11.1 /version /dependency /dependencies Gradle Groovy// No need to add the spring-native dependency explicitly with Gradle, the Spring AOTplugin will add it automatically.Gradle Kotlin// No need to add the spring-native dependency explicitly with Gradle, the Spring AOTplugin will add it automatically.Add the Spring AOT pluginThe Spring AOT plugin performs ahead-of-time transformations required to improve native imagecompatibility and footprint.12

Maven build plugins !-- . -- plugin groupId org.springframework.experimental /groupId artifactId spring-aot-maven-plugin /artifactId version 0.11.1 /version executions execution id generate /id goals goal generate /goal /goals /execution execution id test-generate /id goals goal test-generate /goal /goals /execution /executions /plugin /plugins /build Gradle Groovyplugins {// .id 'org.springframework.experimental.aot' version '0.11.1'}Gradle Kotlinplugins {// .id("org.springframework.experimental.aot") version "0.11.1"}The plugin provides a number of options to customize the transformations, see [spring-aotconfiguration] for more details.Add the native build tools pluginGraalVM provides Gradle and Maven plugins to invoke the native image compiler from your build.The following example adds a native profile that triggers the plugin during the package phase:13

Maven profiles profile id native /id dependencies !-- Required with Maven Surefire 2.x -- dependency groupId org.junit.platform /groupId artifactId junit-platform-launcher /artifactId scope test /scope /dependency /dependencies build plugins plugin groupId org.graalvm.buildtools /groupId artifactId native-maven-plugin /artifactId version 0.9.9 /version extensions true /extensions executions execution id build-native /id goals goal build /goal /goals phase package /phase /execution execution id test-native /id goals goal test /goal /goals phase test /phase /execution /executions configuration !-- . -- /configuration /plugin !-- Avoid a clash between Spring Boot repackaging and nativemaven-plugin -- plugin groupId org.springframework.boot /groupId artifactId spring-boot-maven-plugin /artifactId configuration classifier exec /classifier /configuration /plugin /plugins /build 14

/profile /profiles Gradle Groovy// The GraalVM native build tools plugin is applied and configured automaticallyGradle Kotlin// The GraalVM native build tools plugin is applied and configured automatically When used with Spring AOT, Native Build Tools Gradle toolchain support isdisabled by default in order to avoid current limitations related to identifying in areliable way JDK with native capabiliti

spring-aot-gradle-plugin: Gradle plugin that invokes AOT transformations. spring-aot-maven-plugin: Maven plugin that invokes AOT transformations. samples: contains various samples that demons

Related Documents:

NATIVE INSTRUMENTS GmbH Schlesische Str. 29-30 D-10997 Berlin Germany www.native-instruments.de NATIVE INSTRUMENTS North America, Inc. 6725 Sunset Boulevard 5th Floor Los Angeles, CA 90028 USA www.native-instruments.com NATIVE INSTRUMENTS K.K. YO Building 3F Jingumae 6-7-15, Shibuya-ku, Tokyo 150-0001 Japan www.native-instruments.co.jp NATIVE .

NATIVE INSTRUMENTS GmbH Schlesische Str. 29-30 D-10997 Berlin Germany www.native-instruments.de NATIVE INSTRUMENTS North America, Inc. 6725 Sunset Boulevard 5th Floor Los Angeles, CA 90028 USA www.native-instruments.com NATIVE INSTRUMENTS K.K. YO Building 3F Jingumae 6-7-15, Shibuya-ku, Tokyo 150-0001 Japan www.native-instruments.co.jp NATIVE .

React-Native Apps JS components render as native ones Learn once, write everywhere 13 Android Android SDKs Native UI JS Runtime React Native 3rd Party Libs NPM Pkgs (e.g., React) Bridge Your App Your App (JS) (Native UI & Modules) iOS iOS SDKs Native UI JS Runtime React Native 3 Party Libs NPM Pkgs (e

Native Village of Port Heiden Lake and Peninsula Borough Meshik Inc. Bristol Bay Native Corporation Port Heiden Native Village of Port Lions Kodiak Island Borough Afognak Native Corp Koniag, Incorporated Port Lions Native Village of Ruby Yukon-Koyukuk Census Area Dineega Corp Doyon, Limited Ruby Native Village of Saint Michael Nome Census Area .

NATIVE INSTRUMENTS GmbH Schlesische Str. 29-30 D-10997 Berlin Germany www.native-instruments.de NATIVE INSTRUMENTS North America, Inc. 6725 Sunset Boulevard 5th Floor Los Angeles, CA 90028 USA www.native-instruments.com NATIVE INSTRUMENTS K.K. YO Building 3F Jingumae 6-7-15, Shibuya-ku, Tokyo 150-0001 Japan www.native-instruments.co.jp NATIVE .

If you plan to make changes in Java code, we recommend Gradle Daemon which speeds up the build. Testing your React Native Installation Use the React Native command line tools to generate a new React Native project called "AwesomeProject", then run react-native run-ios inside the newly created folder. react-native init AwesomeProject cd .

NATIVE INSTRUMENTS GmbH Schlesische Str. 29-30 D-10997 Berlin Germany www.native-instruments.de NATIVE INSTRUMENTS North America, Inc. 6725 Sunset Boulevard 5th Floor Los Angeles, CA 90028 USA www.native-instruments.com NATIVE INSTRUMENTS K.K. YO Building 3F Jingumae 6-7-15, Shibuya-ku, Tokyo 150-0001 Japan www.native-

Sep 20, 2021 · 0 – American Indian or Alaska Native and Asian . 1 – American Indian or Alaska Native and Black . or African American . 2 American Indian or Alaska Native and Native Hawaiian or Other Pacific Islander American Indian or Alaska Native and White 4 Asian and Black or African American : 5 Asian and Native Hawaiian or Other 6 Asian and White