单个 web 应用程序或上下文的多个 war 文件

发布于 2024-12-09 03:33:24 字数 1353 浏览 1 评论 0原文

我有一个具有以下结构的应用程序

$TOMCAT_HOME/webapps/myapp
            |-css
                |-myapp.css
            |-js
                |-myapp.js
            |-forum
                |-index.jsp
                |-list.jsp
                |-users.jsp
            |-Articles
                |-index.jsp
                |-ListArticles.jsp
            |-Guestbook
                |-viewGuestBook.jsp
                |-AddnewEntry.jsp
            |-WEB-INF
                |-classes
                    com
                     |-myapp
                        |-forum
                            |-DisplayForum.class
                            |-ListUsers.class
                        |-article
                            |-ArticleList.class
                            |-AddArticle.class
                        |-guestbk
                            |-LoadGuestBook.class
                            |-ProcessGuestBook.class

该应用程序作为 war 文件(即 myapp.war)提供,并部署到 $TOMCAT_HOME/webapps 文件夹中。如果任何文件发生更改(jsp、css、js 或 java 文件),我必须始终重建整个 war 文件。这意味着我在每个版本上部署每个文件。

我想知道是否有办法部署应用程序的特定区域。我特别感兴趣是否可以将应用程序分成多个 war 文件。即 myapp.war、articles.war 和 forum.war。我仍然想通过相同的上下文访问应用程序,即 http://0.0.0.0/myapp 即使多个使用 war 文件。

使用这种方法,我将能够仅交付受更改影响的模块。这有可能吗?

我不介意在部署每个 war 文件后必须重新启动容器。

I have an application that has the following structure

$TOMCAT_HOME/webapps/myapp
            |-css
                |-myapp.css
            |-js
                |-myapp.js
            |-forum
                |-index.jsp
                |-list.jsp
                |-users.jsp
            |-Articles
                |-index.jsp
                |-ListArticles.jsp
            |-Guestbook
                |-viewGuestBook.jsp
                |-AddnewEntry.jsp
            |-WEB-INF
                |-classes
                    com
                     |-myapp
                        |-forum
                            |-DisplayForum.class
                            |-ListUsers.class
                        |-article
                            |-ArticleList.class
                            |-AddArticle.class
                        |-guestbk
                            |-LoadGuestBook.class
                            |-ProcessGuestBook.class

The application is delivered as a war file (i.e. myapp.war) and is deployed into the $TOMCAT_HOME/webapps folder. If any of the files change (either the jsp, css, js or java files) i have to always rebuild the whole war file. This means i deploy every single file on every release.

I am wondering if there is a way to deploy specific areas of the application. I am particularly interested if it is possible to separate the application into multiple war files. i.e. myapp.war, articles.war and forum.war. I would like to still access the application via the same context i.e. http://0.0.0.0/myapp even though multiple war files are used.

Using this approach, i will be able to deliver just the module that was affected by the change. Is this at all possible?

I dont mind having to restart the container after each war file is deployed.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺渁∝ 2024-12-16 03:33:24

我不记得在 Tomcat 中你是如何做到这一点的,你可能需要做一些手动配置(在 context.xml 或类似的东西中),但我相当确定你可以使用以下命令部署你的三个应用程序(.wars)以下上下文路径:

  • myapp.war -> /myapp
  • 文章.war -> /myapp/articles
  • forum.war -> /myapp/forum

我在这里找到了一些特定于 Tomcat 的信息:

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

具体来说:

在各个文件(带有“.xml”扩展名)中
$CATALINA_BASE/conf/[引擎名]/[主机名]/目录。的名字
该文件(减去 .xml 扩展名)将用作上下文路径。
可以使用 # 定义多级上下文路径,例如 foo#bar.xml
/foo/bar 的上下文路径。可以定义默认的 Web 应用程序
通过使用名为 ROOT.xml 的文件。

或者,您可能想要执行以下操作:

  • myapp.war -> /(将其称为 ROOT.war)
  • articles.war -> /articles
  • forum.war -> /forum

话虽如此,请记住,如果您这样做,您将无法毫不费力地在三个应用程序之间共享状态(会话信息)。例如,如果“forum.war”需要身份验证,则该身份验证信息将不可用于 myapp.war 或articles.war。

I don't remember how you do this is Tomcat exactly, you'll probably have to do some manual configuration (in context.xml or something like that) but I'm fairly certain you can deploy your three applications (.wars) with the following context paths:

  • myapp.war -> /myapp
  • articles.war -> /myapp/articles
  • forum.war -> /myapp/forum

I've found a bit of information specific to Tomcat here:

http://tomcat.apache.org/tomcat-6.0-doc/config/context.html

Specifically:

In individual files (with a ".xml" extension) in the
$CATALINA_BASE/conf/[enginename]/[hostname]/ directory. The name of
the file (less the .xml extension) will be used as the context path.
Multi-level context paths may be defined using #, e.g. foo#bar.xml for
a context path of /foo/bar. The default web application may be defined
by using a file called ROOT.xml.

Alternatively, you may want to do something like:

  • myapp.war -> / (by calling it ROOT.war)
  • articles.war -> /articles
  • forum.war -> /forum

Having said that, keep in mind that if you do this, you'll not be able to have shared state (session information) between the three applications without some effort. For instance, if "forum.war" requires authentication, that authentication information will not be available to myapp.war or articles.war.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文