如何使Spring-Boot泽西鞋应用程序具有@ApplicationPath值的别名?
我们有一堆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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论