java-add-graalvm-native-image-support
Skill này làm gì
Agent này giúp thêm hỗ trợ tạo native image cho ứng dụng Java bằng GraalVM. Nó cấu hình dự án, xây dựng image và sửa lỗi cho đến khi mọi thứ hoạt động.
Khi nào nên dùng
- ✓Khi bạn muốn ứng dụng Java của mình khởi động nhanh hơn.
- ✓Khi bạn muốn ứng dụng Java dùng ít bộ nhớ hơn.
- ✓Khi bạn muốn phân phối ứng dụng dưới dạng một file thực thi duy nhất.
Liên kết skill
https://github.com/github/awesome-copilot/blob/main/skills/java-add-graalvm-native-image-support/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Hãy thêm hỗ trợ GraalVM native image cho dự án Maven Spring Boot của tôi và sửa mọi lỗi build.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent phân tích dự án để biết đó là Maven hay Gradle và dùng framework nào. Sau đó, nó thêm các cấu hình cần thiết và thử build native image, đồng thời sửa các lỗi thường gặp như reflection hoặc truy cập tài nguyên, cho đến khi build thành công.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
GraalVM Native Image Agent
You are an expert in adding GraalVM native image support to Java applications. Your goal is to:
- Analyze the project structure and identify the build tool (Maven or Gradle)
- Detect the framework (Spring Boot, Quarkus, Micronaut, or generic Java)
- Add appropriate GraalVM native image configuration
- Build the native image
- Analyze any build errors or warnings
- Apply fixes iteratively until the build succeeds
Your Approach
Follow Oracle's best practices for GraalVM native images and use an iterative approach to resolve issues.
Step 1: Analyze the Project
- Check if
pom.xmlexists (Maven) orbuild.gradle/build.gradle.ktsexists (Gradle) - Identify the framework by checking dependencies:
- Spring Boot:
spring-boot-starterdependencies - Quarkus:
quarkus-dependencies - Micronaut:
micronaut-dependencies
- Spring Boot:
- Check for existing GraalVM configuration
Step 2: Add Native Image Support
For Maven Projects
Add the GraalVM Native Build Tools plugin within a native profile in pom.xml:
<profiles>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>[latest-version]</version>
<extensions>true</extensions>
<executions>
<execution>
<id>build-native</id>
<goals>
<goal>compile-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
<configuration>
<imageName>${project.artifactId}</imageName>
<mainClass>${main.class}</mainClass>
<buildArgs>
<buildArg>--no-fallback</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
For Spring Boot projects, ensure the Spring Boot Maven plugin is in the main build section:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
For Gradle Projects
Add the GraalVM Native Build Tools plugin to build.gradle:
plugins {
id 'org.graalvm.buildtools.native' version '[latest-version]'
}
graalvmNative {
binaries {
main {
imageName = project.name
mainClass = application.mainClass.get()
buildArgs.add('--no-fallback')
}
}
}
Or for Kotlin DSL (build.gradle.kts):
plugins {
id("org.graalvm.buildtools.native") version "[latest-version]"
}
graalvmNative {
binaries {
named("main") {
imageName.set(project.name)
mainClass.set(application.mainClass.get())
buildArgs.add("--no-fallback")
}
}
}
Step 3: Build the Native Image
Run the appropriate build command:
Maven:
mvn -Pnative native:compile
Gradle:
./gradlew nativeCompile
Spring Boot (Maven):
mvn -Pnative spring-boot:build-image
Quarkus (Maven):
./mvnw package -Pnative
Micronaut (Maven):
./mvnw package -Dpackaging=native-image
Step 4: Analyze Build Errors
Common issues and solutions:
Reflection Issues
If you see errors about missing reflection configuration, create or update src/main/resources/META-INF/native-image/reflect-config.json:
[
{
"name": "com.example.YourClass",
"allDeclaredConstructors": true,
"allDeclaredMethods": true,
"allDeclaredFields": true
}
]
Resource Access Issues
For missing resources, create src/main/resources/META-INF/native-image/resource-config.json:
{
"resources": {
"includes": [
{"pattern": "application.properties"},
{"pattern": ".*\\.yml"},
{"pattern": ".*\\.yaml"}
]
}
}
JNI Issues
For JNI-related errors, create src/main/resources/META-INF/native-image/jni-config.json:
[
{
"name": "com.example.NativeClass",
"methods": [
{"name": "nativeMethod", "parameterTypes": ["java.lang.String"]}
]
}
]
Dynamic Proxy Issues
For dynamic proxy errors, create src/main/resources/META-INF/native-image/proxy-config.json:
[
["com.example.Interface1", "com.example.Interface2"]
]
Step 5: Iterate Until Success
- After each fix, rebuild the native image
…
Câu hỏi thường gặp
GraalVM native image là gì?
Đó là phiên bản ứng dụng Java của bạn được biên dịch trực tiếp thành mã máy, giúp chạy nhanh hơn và nhẹ hơn so với ứng dụng Java thông thường.
Ứng dụng Java của tôi có tương thích với GraalVM Native Image không?
Phần lớn ứng dụng Java hiện đại, đặc biệt là những ứng dụng dùng Spring Boot, Quarkus hoặc Micronaut, đều tương thích. Agent sẽ kiểm tra và cố gắng sửa các vấn đề.
“Reflection errors” là gì?
Đây là các cảnh báo xuất hiện khi native image không biết cách truy cập một số phần của mã trong lúc chạy. Agent có thể giúp cấu hình đúng.
Chi tiết
Mô tả gốc của tác giả
GraalVM Native Image expert that adds native image support to Java applications, builds the project, analyzes build errors, applies fixes, and iterates until successful compilation using Oracle best practices.
repo: github/awesome-copilot
Độ phổ biến
- Sao GitHub
- 40k
- Vị trí xếp hạng
- #7253
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
acquire-codebase-knowledge
40kGiúp agent của bạn hiểu và ghi tài liệu cho một dự án mã nguồn có sẵn. Hữu ích khi đón thành viên mới hoặc nắm tổng quan về kiến trúc.
acreadiness-assess
40kGiúp agent của bạn đánh giá mức độ sẵn sàng cho AI của dự án và tạo báo cáo. Hữu ích để biết dự án đã sẵn sàng dùng công cụ AI đến đâu.
acreadiness-generate-instructions
40kGiúp agent của bạn tạo hướng dẫn cho công cụ AI dựa trên kết quả đánh giá. Hữu ích để cải thiện cách AI làm việc với mã và khắc phục các khoảng trống.
acreadiness-policy
40kGiúp agent của bạn xác định hoặc áp dụng chính sách đánh giá dự án bằng AI. Hữu ích để chuẩn hóa cách đánh giá dự án và đảm bảo tuân thủ.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.