我正在使用 tomcat 9,并尝试从 PreResources 标签下面加载所有与项目相关的 jar。
<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" />
根据“base”中提到的路径,External-lib 文件夹位于 tomcat 目录中。但是当部署应用程序时,我收到以下错误。
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”是您要挂载这些资源的位置。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)