如何将 JAR 文件添加到 IBM WebSphere 服务器中的项目类路径?

How to add a JAR file to the project classpath in IBM WebSphere server?

我可以访问部署在 WebSphere 中的项目。我只创建 .class 个文件并将它们放在 WEB-INF 下。

现在,我的 Java class 之一需要一个 JAR。我无权添加 JAR 并重新部署。只需要将本机C盘的JAR添加到项目的class路径即可;以便它可以在加载时加载 JAR。

我该怎么做?

在传统的 websphere 中又名 "full profile":

如果您不想在构建过程中将其放置在 WEB-INF/lib 中,您可以在管理控制台中将其配置为 "shared library" 然后 将它与一个或多个应用程序相关联。

https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.doc/ae/tcws_sharedlib.html

由于这是一个 GUI,所以我不会费心去详细说明。在管理控制台的顶层,有一个环境 > "Shared libraries" 页面,基本上用于此专用目的。

如果您使用的是 WebSphere Liberty,则可以直接通过 server.xml:

进行等效配置

https://www.ibm.com/support/knowledgecenter/en/SSEQTP_liberty/com.ibm.websphere.wlp.doc/ae/cwlp_sharedlibrary.html

<library id="someLibrary">
   <!-- All the jar files in ther servers lib folder -->
   <fileset dir="${server.config.dir}/lib" includes="*.jar" scanInterval="5s" />
</library>

<application location ="webStore.war">
   <classloader commonLibraryRef="someLibrary" />
</application>