Sharing an application context between two WARs?

前端 未结 7 1157
执笔经年
执笔经年 2020-12-30 08:26

Is there a way to share an app-context between two deployed wars? One war needs to wire-in the services of another, and I don\'t know where to start with this.

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 08:35

    The general purpose of a web application container like tomcat is that each application is able to run independently (so you can stop and start individual apps without affecting others), which means that there has probably been a lot of effort put into their development specifically to prevent you from doing this. So even if you find a loophole, I would suggest against using it unless it is recommended or at least sanctioned by the designers.

    I suggest you start looking for other solutions. For example:

    • Do you really need to share the object instances? If they are stateless you may not need to, and you can simply run a copy of the context in each app.
    • Can you separate the code that you're trying to share into a third WAR that exposes a rest service? Or maybe one of the existing WARs could act as the service.

提交回复
热议问题