Tomcat 6 添加特定于 webapp 的目录来加载类
Tomcat 6 在加载类时首先查找 .../WEB-INF/classes,然后查找 .../WEB-INF/lib。我想向此搜索路径添加另一个目录。该目录只能由特定的 Web 应用程序使用。我想使用上下文 XML 文件来配置它(我认为 Loader http://tomcat.apache.org/tomcat-6.0-doc/config/loader.html 组件)
我已阅读此
http://tomcat.apache.org/tomcat-6.0-doc/class -loader-howto.html
但它似乎没有给我答案。看看这个
http://tomcat。 apache.org/tomcat-6.0-doc/api/org/apache/catalina/loader/WebappLoader.html
看来我可以调用 addRepository 来添加包含类的新 jar 文件或目录。但我不确定在哪里或如何称呼它。
Tomcat 6 first looks in .../WEB-INF/classes, then .../WEB-INF/lib when loading classes. I'd like to add another directory to this search path. This directory must only be used by a specific webapp. I'd like to configure this using a context XML file (I'm thinking the Loader http://tomcat.apache.org/tomcat-6.0-doc/config/loader.html component)
I've read this
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html
but it doesn't seem to have an answer for me. Looking at this
http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/loader/WebappLoader.html
It seems I could call addRepository to add a new jar file or directory containing classes. But I'm not sure where or how I would call this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些功能只能由tomcat本身来完成。出于安全考虑,你无法决定在哪里加载类,除非你修改tomcat源代码并重新编译它们,但这不是一个明智的想法。
These functionality can only be done by tomcat itself.You cannot decide where to load classes because of security concerns unless you modify the tomcat source code and recompile them, but that's not a wise idea.