← 返回首页 ❓ 面试题库
📑 本篇章节导航 (共5章,点击直达)
一、GraalVM基础(1-10)二、Native Image实战(11-22)三、云原生Java(23-32)四、性能对比与选型(33-42)五、云原生实战案例(43-50)

Q38 - GraalVM云原生实战


一、GraalVM基础(1-10)

GraalVM是什么?与传统JDK的区别?

★★★★★

JIT vs AOT的区别?

★★★★★

Native Image的编译原理?

★★★★

Native Image的限制?

★★★★★

Native Image的配置文件怎么生成?

★★★★★

Spring Boot 3.x的Native Image支持?

★★★★★


# 方式一:Buildpacks(推荐)
mvn -Pnative spring-boot:build-image

# 方式二:GraalVM直接编译
mvn -Pnative package
native-image -jar target/app.jar

Native Image的GC选择?

★★★★

Native Image的启动性能为什么这么快?

★★★★

Native Image的调试和监控?

★★★

GraalVM的Truffle多语言框架?

★★★


Context context = Context.create();
context.eval("js", "console.log('Hello from JS')");
Value result = context.eval("python", "2 + 3");

二、Native Image实战(11-22)

Native Image的构建环境配置?

★★★★


FROM ghcr.io/graalvm/native-image-community:21 AS builder
WORKDIR /app
COPY . .
RUN ./mvnw -Pnative package
FROM gcr.io/distroless/java-base
COPY --from=builder /app/target/app /app
ENTRYPOINT ["/app"]

Native Image的反射配置?

★★★★★


[
  {
    "name": "com.example.MyClass",
    "allDeclaredConstructors": true,
    "allPublicMethods": true,
    "allDeclaredFields": true
  }
]

Native Image与第三方库兼容性?

★★★★

Native Image的资源文件处理?

★★★★


{
  "resources": {
    "includes": [
      {"pattern": "application.yml"},
      {"pattern": "templates/.*"}
    ]
  }
}

Native Image的构建优化?

★★★★

Native Image在K8s中的部署?

★★★★★


# 多阶段构建
FROM ghcr.io/graalvm/native-image-community:21 AS build
COPY . .
RUN ./mvnw -Pnative package

FROM gcr.io/distroless/java-base-debian12
COPY --from=build /app/target/app /app
EXPOSE 8080
ENTRYPOINT ["/app"]

Native Image的测试策略?

★★★★

Native Image与虚拟线程?

★★★★

Native Image的日志框架兼容?

★★★

Native Image的数据库访问?

★★★★

Native Image的HTTP客户端?

★★★★

Native Image的常见构建错误?

★★★★


三、云原生Java(23-32)

云原生Java的核心特征?

★★★★★

CRaC(Coordinated Restore at Checkpoint)?

★★★★

Spring Boot 3.x的Layertools?

★★★★


FROM eclipse-temurin:21-jre AS builder
WORKDIR /app
COPY target/*.jar app.jar
RUN java -Djarmode=layertools -jar app.jar extract

FROM eclipse-temurin:21-jre
COPY --from=builder /app/dependencies/ ./
COPY --from=builder /app/spring-boot-loader/ ./
COPY --from=builder /app/snapshot-dependencies/ ./
COPY --from=builder /app/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]

Java应用的Serverless部署?

★★★★

云原生Java的可观测性?

★★★★

Java应用的容器资源规划?

★★★★


resources:
  requests: { cpu: "500m", memory: "512Mi" }
  limits: { cpu: "2000m", memory: "1Gi" }

Distroless基础镜像?

★★★★

Java应用的启动优化(非Native Image)?

★★★★

云原生Java的安全?

★★★★

云原生Java的12-Factor App?

★★★★


四、性能对比与选型(33-42)

Native Image vs JIT的性能对比?

★★★★★

什么时候用Native Image?什么时候不用?

★★★★★

Native Image的PGO优化?

★★★★

Spring Boot应用的三种运行模式?

★★★★

Native Image的构建时间优化?

★★★★

Native Image在微服务架构中的实践?

★★★★★

Java在云原生时代的竞争力?

★★★★

Native Image的日志和追踪?

★★★★

Native Image的多平台交叉编译?

★★★

GraalVM vs OpenJDK选型?

★★★★


五、云原生实战案例(43-50)

Spring Boot微服务的Native Image最佳实践?

★★★★★

Native Image与AI应用?

★★★★

Native Image的CI/CD流水线设计?

★★★★


# GitLab CI示例
native-build:
  stage: build
  image: ghcr.io/graalvm/native-image-community:21
  script:
    - ./mvnw -Pnative package
  artifacts:
    paths: [target/app]
  cache:
    key: native-image-cache
    paths: [.native-image-cache/]

docker-build:
  stage: package
  script:
    - docker build -t registry.example.com/app:native .
    - docker push registry.example.com/app:native

Native Image的故障排查?

★★★★

企业级Java云原生迁移路线?

★★★★

Native Image的Licensing?

★★★

Native Image vs Go vs Rust在云原生场景的对比?

★★★★

维度Java Native ImageGoRust
启动时间50ms10ms5ms
内存占用50-100MB10-30MB5-20MB
峰值性能高中最高
开发效率高(Spring生态)高低(学习曲线陡)
生态最丰富云原生丰富增长中
人才最多多少

云原生Java面试必答题总结?

★★★★★