如何在另一个Maven项目中从可执行JAR访问API终点

发布于 2025-01-26 02:13:32 字数 334 浏览 3 评论 0原文

我有一个场景,我的后端API是在Springboot中构建的。我需要将API项目构建为可执行JAR,并希望在另一个项目中使用它。这是我使用前端代码的基本Maven项目。我想在前端项目中包括我的可执行罐,然后想直接从罐子中访问API终点。没有给出前端代码中的任何参考。我需要在POM中为此做什么配置?我尝试过多种在线解决方案,但它们都没有使用。如果我尝试从Frontend Project访问API终点,我将始终获得404。 注意:最终部署应在带有前端代码和API JAR的Tomcat服务器上进行,并在同一战争文件中并部署在Tomcat中。因此,我应该能够直接从JAR访问后端API。

如果有人可以为此提供帮助,那将是很大的帮助。提前致谢。

I have one scenario where I have backend API which is build in springboot. I need to build API project as executable jar and want to use that in another project. which is basic maven project where I am using frontend code. I want to include my executable jar in frontend project and then want to access the API end point directly from the jar. Without giving any reference in frontend code. What configuration I need to do for this in POM? I have tried multiple online solution but none of them working. I am getting 404 always if I try to access the API end point from frontend project.
Note: Final deployment should happen on Tomcat server with Frontend code and API jar both in same War file and deployed in tomcat. So I should be able to access the Backend API directly from jar.

If anyone can help on this it would be great help. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文