gpt4 book ai didi

java - tomcat 将模块 war 部署到子 url 路径

转载 作者:行者123 更新时间:2023-11-28 23:21:24 25 4
gpt4 key购买 nike

我有一个多模块 Maven 项目,其结构如下所示:

app                // parent/root project folder
|- src
|- target
|- app.war // common features
|- app-payment // child/module folder
|- src
|- target
|- app-payment.war // shop/pay features

如何将两个 war 文件映射到如下所示的 url?

requests for    
localhost:8080/app/payment --goto--> $CATALINA_HOME/webapps/app-payment.war (or any other locations, doesn't matter)
other requests for
localhost:8080/app --goto--> $CATALINA_HOME/webapps/app.war

web.xml -> <servlet-mapping>都是<url-pattern>/</url-pattern> .

我使用的是 tomcat 8.5 并希望尽可能保留默认设置(例如,不要在 server.xml 中添加 <Context>,保留 autoDeploy=true)。因此,A word on Contexts 中提供的方法可能位于 https://tomcat.apache.org/tomcat-8.5-doc/deployer-howto.html行不通(无论如何都试过了,但不行)。

万一这被证明是一个 XY 问题...使用/修改 tomcat 来实现这样的 url 模式是否是正确的方法?还是我应该更改项目设置(或设计)?这是一个 spring-mvc 项目,整个 spring-*.xml 就像一个神话......


catalina.2017-03-29.log:

29-Mar-2017 17:28:49.472 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina29-Mar-2017 17:28:49.472 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.529-Mar-2017 17:28:49.494 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive C:\Program_Files\tomcat-8.5.5\webapps\payment.war29-Mar-2017 17:28:49.505 WARNING [localhost-startStop-1] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.29-Mar-2017 17:28:51.071 INFO [localhost-startStop-1] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.29-Mar-2017 17:28:52.480 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive C:\Program_Files\tomcat-8.5.5\webapps\payment.war has finished in 2,985 ms29-Mar-2017 17:28:52.482 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program_Files\tomcat-8.5.5\webapps\docs29-Mar-2017 17:28:52.494 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:\Program_Files\tomcat-8.5.5\webapps\docs has finished in 12 ms29-Mar-2017 17:28:52.494 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory C:\Program_Files\tomcat-8.5.5\webapps\examples

最佳答案

尝试更改 war 文件的 context.xml

 <Context antiJARLocking="true" path="/app/payment"/>

默认是

 <Context antiJARLocking="true" path="/app-payment"/>

关于java - tomcat 将模块 war 部署到子 url 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43089000/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com