Tomcat:PreResources标签不加载罐子
问题描述:
我正在使用tomcat 9,并尝试从下面的PreResources标签加载所有项目相关的罐子。Tomcat:PreResources标签不加载罐子
<Resources className="org.apache.catalina.webresources.StandardRoot" cachingAllowed="true" cacheMaxSize="100000" allowLinking="true">
<PreResources className="org.apache.catalina.webresources.DirResourceSet"
base="D:\SomePath\apache-tomcat-9.0.0.M17-windows-x64-2\apache-tomcat-9.0.0.M17"
internalPath="/External-lib"
webAppMount="/WEB-INF/classes" />
External-lib文件夹位于tomcat目录中,按照'base'中提到的路径。但是当应用程序被部署时,我会得到以下错误。
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
这会从web.xml中调用,
org.springframework.web.context.ContextLoaderListener
在Tomcat的lib,我们刚刚tomcat的图书馆,那里的其余所有jar的是在External-lib文件夹中。由于我们有类似的webApp和jar太多,我们正试图将它们外部化,而不是加载到webapp/web-inf/lib文件夹中。
请建议,我是否在使用PreResources元素从meta-inf/context.xml加载jar时错过了任何内容。
这个PreResources元素的例子和文档非常少。 任何方向或帮助,将不胜感激。
答
这应该是context.xml的内容。它工作并解决了我的问题。
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resources>
<PreResources className="org.apache.catalina.webresources.DirResourceSet"
base="SomePath\External-lib\"
webAppMount="/WEB-INF/lib" />
</Resources>
</Context>
“Base”是通向外部资源的路径,“webAppMount”是您要装入这些资源的位置。