You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用rapidoid-rest创建Maven项目时遇On类依赖缺失问题

解决Rapidoid项目中On类无法找到的问题

嘿,你遇到的问题其实很好解决——On类并不包含在你当前引入的rapidoid-rest依赖包里,它属于rapidoid-http-server模块的核心路由API,所以必须额外引入这个依赖才能正常使用。

步骤1:更新你的pom.xml

把rapidoid-http-server依赖添加到你的依赖列表中,注意版本要和rapidoid-rest保持一致(这里都是5.0.12):

<dependencies>
    <dependency>
        <groupId>org.rapidoid</groupId>
        <artifactId>rapidoid-rest</artifactId>
        <version>5.0.12</version>
    </dependency>
    <!-- 添加这个依赖以获取On类 -->
    <dependency>
        <groupId>org.rapidoid</groupId>
        <artifactId>rapidoid-http-server</artifactId>
        <version>5.0.12</version>
    </dependency>
</dependencies>

补充说明

rapidoid-rest主要负责REST风格的响应处理、数据序列化等辅助功能,而HTTP请求路由的核心类(比如On、Post这类路由注解/类)都封装在rapidoid-http-server模块里,两者是协作关系,缺一不可。

更新完依赖后,你的代码On.get("/example").json("example")就能正常编译运行了,启动项目后访问对应路径就能看到预期的JSON响应啦。

内容的提问来源于stack exchange,提问作者Sezin Karli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:39:06