Parent pom providing dependency and plugin management for applications built with Maven
—
GraalVM native image compilation support for creating native executables with fast startup times and low memory footprint, ideal for cloud-native deployments and serverless environments.
Maven profile that enables GraalVM native compilation with required plugin configurations.
/**
* Native compilation profile for GraalVM native image creation
* Activates additional plugin configurations for AOT processing
*/
<profile>
<id>native</id>
<build>
<plugins>
<!-- Native-specific plugin configurations -->
</plugins>
</build>
</profile>Usage Examples:
# Build native executable
mvn -Pnative native:compile
# Build and test native executable
mvn -Pnative package
# Create native executable with specific name
mvn -Pnative native:compile -Dapp.name=my-native-appEnhanced JAR plugin configuration for native compilation marker.
/**
* Maven JAR plugin native configuration
* Adds manifest entry indicating native processing
*/
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Spring-Boot-Native-Processed>true</Spring-Boot-Native-Processed>
</manifestEntries>
</archive>
</configuration>
</plugin>Spring Boot Maven plugin configuration for Ahead-of-Time compilation.
/**
* Spring Boot Maven plugin AOT processing
* Generates optimized code and configuration for native compilation
*/
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>process-aot</id>
<goals>
<goal>process-aot</goal>
</goals>
</execution>
</executions>
</plugin>Core GraalVM native image plugin configuration for native executable creation.
/**
* GraalVM native Maven plugin for native image compilation
* Requires GraalVM 22.3 or later for Spring Boot native support
*/
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<requiredVersion>22.3</requiredVersion>
</configuration>
<executions>
<execution>
<id>add-reachability-metadata</id>
<goals>
<goal>add-reachability-metadata</goal>
</goals>
</execution>
</executions>
</plugin>Profile for running native tests to verify native compilation compatibility.
/**
* Native test profile for testing native compilation
* Includes JUnit Platform Launcher for native test execution
*/
<profile>
<id>nativeTest</id>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Native test plugin configurations -->
</plugins>
</build>
</profile>Spring Boot plugin configuration for native test AOT processing.
/**
* Spring Boot Maven plugin for native test AOT processing
* Optimizes test code for native test execution
*/
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>process-test-aot</id>
<goals>
<goal>process-test-aot</goal>
</goals>
</execution>
</executions>
</plugin>GraalVM plugin configuration for executing tests in native mode.
/**
* GraalVM native plugin for native test execution
* Runs tests as native images to verify native compatibility
*/
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<requiredVersion>22.3</requiredVersion>
</configuration>
<executions>
<execution>
<id>native-test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin># Regular Spring Boot development
mvn spring-boot:run
# Test for native compatibility
mvn -PnativeTest test
# Build native executable
mvn -Pnative native:compile
# Run native executable
./target/my-app# Full native build with tests
mvn clean -Pnative package
# Native compilation only
mvn -Pnative clean compile native:compile
# Native test execution
mvn -PnativeTest clean test
# Build native executable with custom JVM arguments
mvn -Pnative native:compile -Dnative.build.args="--enable-preview,-H:+UnlockExperimentalVMOptions"# Multi-stage build for native executable
FROM ghcr.io/graalvm/graalvm-ce:java17 AS builder
WORKDIR /app
COPY pom.xml .
COPY src src
# Build native executable
RUN mvn -Pnative clean package
# Runtime stage
FROM scratch
COPY --from=builder /app/target/my-app /app
ENTRYPOINT ["/app"]# Native-specific configuration
spring.native.remove-unused-autoconfig=true
spring.aot.enabled=true
# GraalVM native image options
spring.graalvm.reachability-metadata.enabled=true@Configuration
@RegisterReflectionForBinding({User.class, Product.class})
public class NativeConfiguration {
@Bean
@RegisterReflectionForBinding(DatabaseConfig.class)
public DataSource dataSource() {
return new HikariDataSource();
}
}@Component
public class MyRuntimeHints implements RuntimeHintsRegistrar {
@Override
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.reflection().registerType(MyClass.class,
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS);
}
}| Metric | JVM | Native |
|---|---|---|
| Startup Time | 2-5 seconds | 50-200ms |
| Memory Usage | 100-500MB | 20-100MB |
| Peak Performance | Higher | Lower |
| Build Time | Fast | Slow |
<!-- Optimize for size -->
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<buildArgs>
<buildArg>--no-fallback</buildArg>
<buildArg>-H:+ReportExceptionStackTraces</buildArg>
<buildArg>-H:+PrintGCDetails</buildArg>
<buildArg>--enable-preview</buildArg>
</buildArgs>
</configuration>
</plugin>Install with Tessl CLI
npx tessl i tessl/maven-org-springframework-boot--spring-boot-starter-parent