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
$ camel update run {camelSpringBootVersion} --runtime=spring-boot
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
$ 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
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
$ 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