如果它们在两个 Web 应用程序中,Tomcat 是否将相同的库文件两次加载到内存中? [英] Does Tomcat load the same library file into memory twice if they are in two web apps?

查看:19
本文介绍了如果它们在两个 Web 应用程序中,Tomcat 是否将相同的库文件两次加载到内存中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 tomcat/webapps 文件夹下有两个应用程序.

I have two applications under tomcat/webapps folder.

tomcat/webapps/App1
tomcat/webapps/App2

两个应用程序共享相同的库.例如,它们存储在 tomcat/webapps/App1/WEB-INF/lib 中.

Both applications share the same libraries. Which are stored for example in tomcat/webapps/App1/WEB-INF/lib.

两个库是否在内存中加载了两次?

Are both libraries loaded twice in memory?

我应该把这些共享库放在tomcat/server/lib中吗?

Should I put these shared libraries in tomcat/server/lib?

推荐答案

如您所见 此处,Tomcat 为您服务器上的每个 Web 应用程序创建一个类加载器.因此,如果您的 webapp1 和 webapp2 共享同一个库,那么这个库确实会被加载两次.

As you can see here, Tomcat creates one class-loader per webapp on your server. Thus, if you have webapp1 and webapp2 that share the same library, then this library will be indeed loaded twice.

如果您的 Tomcat 服务器上运行的所有网络应用程序共享该库,您最终可以将该库放在公共目录 (tomcat-dir/common/lib) 中.

You can eventually place this library in the common directory (tomcat-dir/common/lib) if it is shared by all webapps that run on your Tomcat server.

这篇关于如果它们在两个 Web 应用程序中,Tomcat 是否将相同的库文件两次加载到内存中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆