简体   繁体   English

REST中Wildfly中2个不同模块的相同路径

[英]same Path with REST for 2 Different Modules in Wildfly

I am using Wildfly 9 and have 2 different Modules (Wars) I deploy and declare as an Application (Servlet). 我正在使用Wildfly 9,并且有2个不同的模块(战争),我将它们部署并声明为应用程序(Servlet)。

I use Dynamic Web Modules v 3.1 and Application Subclasses with an PathAnnotation without an web.xml file. 我将动态Web模块v 3.1和应用程序子类与没有Web.xml文件的PathAnnotation一起使用。

Now every Module-Path has his own Package-Name in it. 现在,每个模块路径中都有自己的包名称。 For Example Test-Modul localhost:8080/testmodul/ and so one. 例如,Test-Modul localhost:8080/testmodul/等。 But i need 2 different War files to listen on the same path, like localhost:8080/api . 但是我需要2个不同的War文件来侦听同一路径,例如localhost:8080/api

It is not possible to have to different deployments that share the same context. 不可能有共享相同上下文的不同部署。 But the desired result could be achieved by using a reverse proxy in front of the application server. 但是,可以通过在应用程序服务器前面使用反向代理来获得所需的结果。

Actually i found a way because it is possible: 实际上,我找到了一种方法,因为有可能:

In Wildfly you can create an file named "jboss-web.xml" and put it in the WEB-INF folder of the module. 在Wildfly中,您可以创建一个名为“ jboss-web.xml”的文件,并将其放在模块的WEB-INF文件夹中。

In this xml you now can define different things that are not possible in web.xml or on other way. 现在,您可以在此xml中定义web.xml或其他方式无法实现的不同内容。 For Example you can use the option < context-root > to define the path of a module. 例如,您可以使用选项<context-root>定义模块的路径。 In my Example the jboss-web.xml would look like this: 在我的示例中,jboss-web.xml看起来像这样:

<jboss-web>
<context-root>/api/modules</context-root>
</jboss-web>

Now you can reach both deployed modules under: www.localhost:8080/api/modules 现在,您可以在以下位置访问这两个已部署的模块:www.localhost:8080 / api / modules

There are also a lot other possible commands, which you can read about here: https://docs.jboss.org/jbossweb/7.0.x/appdev/jbossweb.html 还有很多其他可能的命令,您可以在这里阅读: https : //docs.jboss.org/jbossweb/7.0.x/appdev/jbossweb.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM