惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
A
Arctic Wolf
C
CERT Recently Published Vulnerability Notes
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Vercel News
Vercel News
P
Palo Alto Networks Blog
N
News and Events Feed by Topic
Simon Willison's Weblog
Simon Willison's Weblog
L
LINUX DO - 最新话题
阮一峰的网络日志
阮一峰的网络日志
C
CXSECURITY Database RSS Feed - CXSecurity.com
Google DeepMind News
Google DeepMind News
Project Zero
Project Zero
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
WordPress大学
WordPress大学
The Last Watchdog
The Last Watchdog
博客园_首页
D
Docker
MyScale Blog
MyScale Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Hacker News
The Hacker News
云风的 BLOG
云风的 BLOG
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
The Blog of Author Tim Ferriss
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
S
Schneier on Security
C
Check Point Blog
I
Intezer
S
Securelist
雷峰网
雷峰网
小众软件
小众软件
C
Cyber Attacks, Cyber Crime and Cyber Security
PCI Perspectives
PCI Perspectives
S
Security @ Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
量子位
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
A
About on SuperTechFans
T
Troy Hunt's Blog
Google Online Security Blog
Google Online Security Blog
F
Fortinet All Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
Security Archives - TechRepublic
Security Archives - TechRepublic
Latest news
Latest news

czp's blog

Ubuntu 下使用 zsh · HonKit 使用 VNC 来远程管理服务器 · HonKit Linux 下无限试用 JetBrains · HonKit 使用 KMS 激活 Windows · HonKit 为 KVM 中的 Windows 虚拟机启用 VirtIO · HonKit 在 Spring Boot 中处理 MissingKotlinParameterException · HonKit 用 Spring Native 拯救微服务 · HonKit 正确调试 PHP · HonKit Ubuntu 增加最大文件打开数量限制 · HonKit 将 Minecraft 服务端编译到 native · HonKit 用凝聚力购买 P 社游戏 DLC · HonKit 模拟超星网课 Android 客户端 · HonKit 模拟 Bilibili Android 客户端 · HonKit 模拟哔咔 Android 客户端 · HonKit 异步是什么 · HonKit GCP Pub/Sub push 至 IAP 保护的 Endpoint · HonKit 多个 Gradle SubProject 同时编译导致 CI/CD 内存耗尽 · HonKit Google Cloud Build 运行 DIND · HonKit 在 Google Storage 中部署 SPA · HonKit Terraform 不自动更新 CloudRun service · HonKit Telegram Bot 收不到普通群聊消息的问题 · HonKit 加密货币交易 · HonKit 挖掘以太坊 · HonKit 挖掘门罗币 · HonKit 小明学英语 · HonKit 卖程序的小女孩 · HonKit 一个测试工程师走进一家酒吧 · HonKit 我给你们讲个 TCP 笑话吧! · HonKit 我给你们讲个 UDP 笑话吧! · HonKit 格局打开 · HonKit c 语言常见未定义行为 · HonKit 在 Kotlin 使用 SpaceEngineers Remote API · HonKit Kotlin 协程 · HonKit 在 Spring Boot 中正确注册 Jackson Module · HonKit Spring Boot Jpa 使用 Google Cloud SQL · HonKit Spring Boot 中配置单页应用 · HonKit Spring Boot 无法加载 ClasspathResource 问题 · HonKit 正确打包 Spring Boot 到 war · HonKit czp's blog · HonKit 鸣谢列表 · HonKit 友链 · HonKit
部署 Spring Native 到 GCP App Engine · HonKit
2026-04-11 · via czp's blog

本文撰写时的 Spring Boot 版本: 2.7.7, Spring Native 版本: 0.12.2

与其他语言不同的是, App Engine 对 Java 的支持是通过 gradle(或者 maven)插件实现的, 而不是手动执行 gcloud 命令行来提交文件. 但是默认情况下, 插件会找到 jar 命令的 artifact 然后提交上去, 所以即使在项目中使用了 spring native, 也不会让部署的文件变成 graalvm native image 的 artifact.

为了迁移到 spring native, 需要配置 gradle, 手动为 appengine 插件指定 artifact

appengine {
    stage {
        //假设使用默认的 nativeBuild 输出路径
        artifact = project.buildDir.toPath()
                .resolve('native')
                .resolve('nativeCompile')
                .resolve(project.name)
    }
}
//使 nativeBuild 先于 appengineStage 执行
appengineStage.dependsOn tasks.nativeBuild

与此同时, 对应的 app.yaml 文件也需要做出修改. App Engine 并没有单独的对二进制可执行文件的支持, 但是在任何运行时中都可以通过配置 entrypoint 来覆盖默认的 docker 的 ENTRYPOINT. 举个例子:

service: default
runtime: java17
instance_class: F1

entrypoint: ./application  #二进制文件的文件名, 默认为项目名

handlers:
  - url: /.*
    script: auto
    secure: always
    redirect_http_response_code: 301

这样就可以让程序在云上环境中正常运行了.

顺便一提, 在默认情况下 GAE 插件找的也是 jar 命令的输出而不是 bootJar 命令的 artifact, 所以就算不使用 spring native 而是普通的基于 jvm 的 spring, 也要修改插件配置让它用 bootJar 命令输出的 artifact

appengine {
    stage {
        artifact = bootJar.archiveFile.get()
    }
}