在 Websphere Liberty 服务器中配置两个上下文根相同的 war 文件

Configure two context-root same war file in Webpshere Liberty server

正在将应用程序从 ANT (EAR) 迁移到 Maven (WAR)。在 ANT 项目中,我在 WAR 中有 WEB 层,在 JAR 中有 EJB 层。 EJB 模块有WebService 代码。现在正在将 ANT 迁移到 Maven 以后应用程序将只有 WAR。在 ANT 中应用时,我可以有两个不同的上下文根,如 "/webapp""/webservice"。 EJB JAR 存档中定义的上下文根 "/webservice",如下所示,

<webservices-bnd xmlns="http://websphere.ibm.com/xml/ns/javaee" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ws-bnd_1_0.xsd" 
        version="1.0">
    <!-- optional http publishing module overrides -->
    <http-publishing context-root="/webservice" />
</webservices-bnd>

所以我有不同的URL访问WEB和WebService, http://localhost:9080/webapp/application/index.html - 网络应用程序 http://localhost:9080/webservice/service/helloworld?wsdl - 网络服务

根据 IBM 文档https://www.ibm.com/support/knowledgecenter/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/twlp_dep_jaxws_binding.html

当我只有 WAR 文件时,<http-publishing context-root="/webservice" /> 中的

context-root 将不起作用。因此,我只能使用相同的“webapp”上下文根访问 webapp 和 webservice。 但是我需要两个不同的 URL 来访问上面的 webapp 和 webservice。我怎样才能做到这一点?

如果您将 EAR 文件组合成单个 war,则无法覆盖 war 中不同端点的默认值 context-root。

您可以使用 Liberty 的 ibm-ws-bnd.xml 配置文件以及您提到的元素 <http-publishing context-root="/webservice" /> 覆盖 EJB jar 的默认值 context-root。您需要将 EJB Web 服务 jar 文件与 war.

分开打包