问题描述
在Tomcat中,我想在Web应用程序中使用jar。 jar文件将存在于Tomcat目录之外。
In Tomcat I want to use a jar inside a web application. The jar file will exist outside of the Tomcat directory.
要将jar文件包含在tomcat类路径中,我修改了TomcatHome / conf / catalina.properties以包含我的jar文件的绝对路径,如
To include the jar file in tomcat classpath, I modified the TomcatHome/conf/catalina.properties to include the absolute path of my jar file like,
shared.loader=D:\jaa\MyJarFile.jar
根据链接中给出的建议,
as per the suggestion given in link,
http://www.mulesoft.com/tomcat-classpath
但它会抛出错误,
java.lang.NoClassDefFoundError
我也试过了,
shared.loader=D:\jaa\*.jar
shared.loader=file:\\D:\jaa\MyJarFile.jar
它们似乎都不起作用:(
None of them seem to work :(
如果我尝试将jar放在tomcat / lib中,它似乎可以工作。但我不允许这样做。
If I try placing the jar inside tomcat/lib it seem to work. But I am not allowed to do that.
请帮我解决这个问题,因为我已经在下周实施了这个问题。
Please help me out with this issue as I have implementation the next week..
推荐答案
我想我自己如何为tomcat添加类路径。而不是编辑catalina.properties,只需使用类路径在Tomcat Bin目录中创建setenv.sh,
I figured myself how to add the classpath for tomcat. Instead of editing catalina.properties, just create a "setenv.sh" in the Tomcat Bin directory with the classpath,
示例,
CLASSPATH=D:\jaa\MyJarFile.jar
我刚检查了Tomcat / bin中的catalina.sh,并且在将引导程序设置为类路径时将设置这些classpath变量。
I just checked the catalina.sh in Tomcat/bin and these classpath variable will be set while setting the bootstrap as the classpath.
这篇关于在Tomcat ClassPath中包含外部jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!