单个 web 应用程序或上下文的多个 war 文件
我有一个具有以下结构的应用程序
$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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不记得在 Tomcat 中你是如何做到这一点的,你可能需要做一些手动配置(在 context.xml 或类似的东西中),但我相当确定你可以使用以下命令部署你的三个应用程序(.wars)以下上下文路径:
我在这里找到了一些特定于 Tomcat 的信息:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
具体来说:
或者,您可能想要执行以下操作:
话虽如此,请记住,如果您这样做,您将无法毫不费力地在三个应用程序之间共享状态(会话信息)。例如,如果“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:
I've found a bit of information specific to Tomcat here:
http://tomcat.apache.org/tomcat-6.0-doc/config/context.html
Specifically:
Alternatively, you may want to do something like:
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.