首页 > 解决方案 > Spring Boot Rest 服务应用程序问题与路由逻辑到 mongo db

问题描述

我必须使用 Spring Boot 应用程序创建 api,其中使用 apache camel 和 api 的路由逻辑应该保存到 Mongo db,如果有人创建了这样的应用程序,请提供帮助。

标签: springmongodbspring-bootapache-camel

解决方案


你需要使用 apache camel 的 rest 组件

这是一个使用 apache camel 和 springboot的示例应用程序

 rest("/users").description("User REST service")
                .consumes("application/json")
                .produces("application/json")

                .get().description("Find all users").outType(User[].class)
                .responseMessage().code(200).message("All users successfully returned").endResponseMessage()
                .route()
                .to("bean:userService?method=findUsers")
                .endRest()

在上面的骆驼示例中,我正在为用户创建一个 rest api,它将返回用户列表。


推荐阅读