跳到正文
Skillpedia
API 与服务器(后端)40k · #7255

java-helidon

它能做什么

这个智能体可以按照最佳实践,帮你编写 Helidon 代码。Helidon 是一个 Java 框架。它能确保你的代码使用最新版本(Helidon 4),并且结构清晰。

适用场景

  • ✓当你用 Helidon 4 开始一个新项目时。
  • ✓当你要把旧项目迁移到 Helidon 4 时。
  • ✓当你需要遵循最佳实践的代码示例时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/java-helidon/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/java-helidon/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我该如何用 Maven 搭建一个 Helidon 4 项目?”

每周 5 个新技能,1 分钟读完。

工作原理

它会将你的代码与最新的 Helidon 4 规则进行对比,并建议最佳的项目组织方式、依赖配置方式,以及让代码更好运行的写法。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Helidon Best Practices

Your goal is to help me write high-quality Helidon applications by following established best practices.

Helidon 3 → 4 API changes

Helidon 4 renamed or resignatured APIs that appear widely in their Helidon 3 form. The left column does not compile on Helidon 4. Check generated code against this table before returning it.

Do not use (Helidon 3) Use (Helidon 4)
io.helidon.common.http.Http.Status io.helidon.http.Status
io.helidon.webserver.Service io.helidon.webserver.http.HttpService
Routing.Rules, update(Routing.Rules) HttpRules, routing(HttpRules)
request.path().param("id") request.path().pathParameters().get("id")
String s = column.as(String.class) column.getString() or column.get(String.class)
dbClient.execute(exec -> ...) returning Single/Multi dbClient.execute() returning Optional<DbRow> / Stream<DbRow>
javax.* jakarta.*
helidon-microprofile-tests-junit5 helidon-microprofile-testing-junit5

Value.as(Class) in Helidon 4 returns OptionalValue<T>, not T. This is the single most common Helidon 4 compile error in generated code.

Project Setup & Structure

  • Programming Model: Determine whether the project uses Helidon SE or Helidon MP before generating code. Do not mix the two programming models unless explicitly required.
  • Java Version: Use Java 21 or later for Helidon 4 applications.
  • Build Tool: Use Maven (pom.xml) or Gradle (build.gradle) for dependency management.
  • Dependency Management: Use the Helidon BOM or platform to keep Helidon module versions aligned.
  • Package Structure: Organize code by feature or domain, such as com.example.app.order and com.example.app.customer, rather than only by technical layer.

Helidon SE

  • Explicit Composition: Construct services and dependencies explicitly in the application bootstrap layer.
  • Constructor Injection: Pass required dependencies through constructors and declare dependency fields as private final.
  • HTTP Services: Group related routes in focused HttpService implementations.
  • Business Logic: Keep business logic outside route handlers.
  • Virtual Threads: Prefer straightforward blocking code with Helidon 4 virtual-thread-based request handling. Do not introduce reactive complexity without a clear reason. Helidon 4 is not reactive; do not generate Single, Multi, or CompletionStage chains.

Helidon MP

  • Jakarta and MicroProfile: Prefer standard Jakarta EE and Eclipse MicroProfile APIs when available.
  • Dependency Injection: Use CDI with constructor injection for required dependencies.
  • Bean Scopes: Use CDI scopes such as @ApplicationScoped and @RequestScoped intentionally.
  • Normal-Scoped Beans: Add a non-private no-argument constructor to normal-scoped beans that use constructor injection, so the CDI client proxy can be created portably.
  • Business Logic: Keep Jakarta REST resource classes thin and delegate business operations to service classes.
  • Portability: Prefer portable Jakarta and MicroProfile APIs over Helidon-specific APIs when portability is important.

Configuration

  • Externalized Configuration: Store non-secret configuration in application.yaml or application.properties.
  • Helidon SE Configuration: Use Helidon Config and pass configuration values or typed configuration objects to components.
  • Helidon MP Configuration: Use MicroProfile Config for injected application settings.
  • Environment Overrides: Use environment variables or deployment-specific configuration sources for environment-dependent values.
  • Secrets Management: Never hardcode credentials, API keys, tokens, or private certificates.

Web Layer

…

常见问题

Helidon SE 和 Helidon MP 有什么区别?

Helidon SE(标准版)更基础、更灵活;Helidon MP(MicroProfile)则使用 CDI 和 JAX-RS 等较成熟的标准来构建应用。

为什么要使用 Helidon 4 的 API?

Helidon 4 的 API 经过更新,效率更高,也更安全。使用它们可以避免常见错误,并确保与新版本兼容。

什么是“最佳实践”?

指编写代码的推荐方式和最高效的方法,能让程序更容易理解、更便于维护,也更不容易出错。

详情

作者的原始描述

Get best practices for developing applications with Helidon 4 (SE and MP). Use when working with Helidon SE or Helidon MP, HttpService routing, Helidon DB Client, MicroProfile Config, Helidon Security, or Helidon testing in Java 21+ projects.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7255
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能