如何使Spring-Boot泽西鞋应用程序具有@ApplicationPath值的别名?

发布于 2025-01-25 04:56:08 字数 900 浏览 4 评论 0原文

我们有一堆Springboot应用程序,目前都使用泽西岛(JAX-RS)提供REST服务。

所有这些都有一个“应用程序”类,该类扩展了SpringbootservletInitializer,并带有@springbootapplication注释。

他们都有一个类,可以扩展org.glassfish.jersey.server.resourceconfig,其中构造函数具有一些“ register()”调用注册JAX-RS控制器。该类还具有@ApplicationPath注释,该注释指定了添加到上下文路径中的URL路径。

我们有一个情况,我们想为提供给“ @applicationpath”的值定义“别名”。我正在寻找实施此操作的方法。我注意到applicationpath的Javadoc说:

发布在servlet容器中时,应用程序的值 可以使用web.xml中的servlet映射元素覆盖路径。

现在说“覆盖”,这可能是我想要的也可能不是我想要的。我还注意到,如果我有一个普通的web.xml,我相信我可以有多个指向同一servlet的servlet映射元素。那会绘制这两条路径吗?使用常规的Springboot应用程序,我没有Web.xml,所以我不确定这是否对我有帮助。

我注意到,当我检查org.springframework.boot.web.servlet.support.support.springbootservletinitialializer时,我看到有代码似乎是在操纵对象,这些对象似乎是对它们的模拟的模拟web.xml,所以也许我可以使用该API来添加其他servlet映射?

We have a bunch of SpringBoot applications, all presently using Jersey (JAX-RS) to provide REST services.

All of them have an "Application" class that extends SpringBootServletInitializer and with a @SpringBootApplication annotation.

They all have a class that extends org.glassfish.jersey.server.ResourceConfig where the constructor has some "register()" calls to register jax-rs controllers. This class also has an @ApplicationPath annotation that specifies the url path added to the context-path that all of its controllers listen on.

We have a situation where we would like to define "aliases" for the value provided to "@ApplicationPath". I'm looking for ways to implement this. I note that the javadoc for ApplicationPath says this:

When published in a Servlet container, the value of the application
path may be overridden using a servlet-mapping element in the web.xml.

Now that says "overridden", which may or may not be what I want. I also note that if I had a plain web.xml, I believe I can have multiple servlet-mapping elements pointing to the same servlet. Does that map both paths? With a conventional SpringBoot app, I don't have a web.xml, so I'm not sure if that helps me.

I note that when I inspect org.springframework.boot.web.servlet.support.SpringBootServletInitializer, I see there is code that appear to be manipulating objects that seem like they are analogs of what is defined in the web.xml, so perhaps there's something I can do with that api to add an additional servlet mapping?

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

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

发布评论

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