3.6. 使用 Camel 更新方法在 Spring Boot 版本上升级 Red Hat build of Apache Camel


在 Spring Boot 上迁移 Apache Camel 代码通常涉及适应新的 Camel API 更改和重命名类。要解决这个问题,您可以使用基于 OpenRewrite 的 Camel 更新方法。这些方案有助于手动迁移并提高效率。

您可以使用 Camel JBang 更新 Spring Boot 应用程序上的红帽构建的 Apache Camel。Camel JBang 提供 camel update 命令。它有两个主要操作:

  • 运行 :执行实际更新过程

更新过程使用 Apache Camel Open Rewrite 方法。它支持以下应用程序类型:

  • 普通 Camel (camel-main)
  • Camel Quarkus
  • Camel Spring Boot

在这里,Camel 和 Camel Spring Boot 更新主要使用 camel-upgrade-recipes,而 Camel Quarkus 更新同时涉及 Quarkus 运行时(通过 Rewrite Quarkus)和 Apache Camel 方法。

3.6.1. 运行 Camel 更新

要对此版本执行更新,请使用:

$ camel update run {camelSpringBootVersion} --runtime=spring-boot
Copy to Clipboard Toggle word wrap
注意

update 命令必须在包含 pom.xml 文件的项目目录中执行。

3.6.1.1. 配置选项

您可以使用几个可用选项自定义更新过程:

  • --runtime :指定应用程序类型:

    • spring-boot - Camel Spring Boot 应用程序
  • --repos :在更新过程中使用的额外 Maven 存储库
  • --dry-run: 在不应用它们的情况下预览更改
  • --extraActiveRecipes: Comma 分开的额外方法名称列表
  • --extraRecipeArtifactCoordinates: Comma- separated of Maven reconciles for extra recipes (format: groupId:artifactId:version)
  • --help :查看所有可用选项。

3.6.1.2. 更新普通 Camel 应用程序

以下示例演示了如何更新普通 Camel 应用程序。

$ camel update run 4.10.7.redhat-00013 --runtime=camel-main --repos=https://myMaven/repo --extraActiveRecipes=my.first.Recipe,my.second.Recipe --extraRecipeArtifactCoordinates=ex.my.org:recipes:1.0.0
Copy to Clipboard Toggle word wrap

3.6.1.3. 更新 Spring Boot 应用程序

您可以使用以下命令来更新 Spring Boot 应用程序。您可以使用 -extraActiveRecipes 选项来运行额外的 Spring Boot 升级。

$ camel update run 4.10.7.redhat-00013 --runtime=spring-boot --extraActiveRecipes=org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 --extraRecipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:6.0.2
Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部