Java 如何在 Websphere 应用服务器中配置 Classpath?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2447706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 07:48:13  来源:igfitidea点击:

How to configure Classpath in Websphere application server?

javawebsphere

提问by abhishek jain

I need to add log4j jar in classpath of WAS server but I am unable to put it. Please suggest. I tried to add this jar in start script of WAS server.

我需要在 WAS 服务器的类路径中添加 log4j jar,但我无法放置它。请建议。我试图在 WAS 服务器的启动脚本中添加这个 jar。

回答by Robin

From the Admin console, select Environment->Shared Libraries

在管理控制台中,选择环境-> 共享库

Then in the page displayed, select New and follow the directions to add you library.

然后在显示的页面中,选择新建并按照说明添加您的库。

回答by mransley

It depends why you want to add it. Do you need access to log4j from within your applications, if so you can add it into the application (i.e. in the WEB-INF/lib directory), if you are writing a component that needs to run within the WebSphere runtime (i.e. a JMX library) then you can put it into WebSphere/AppServer/lib/ext.

这取决于您为什么要添加它。您是否需要从您的应用程序中访问 log4j,如果需要,您可以将它添加到应用程序中(即在 WEB-INF/lib 目录中),如果您正在编写需要在 WebSphere 运行时中运行的组件(即 JMX库),然后您可以将其放入 WebSphere/AppServer/lib/ext。

回答by Manglu

As Michael Ransley mentioned, you need to determine who needs log4j. If it is a web application, then WEB-INF/lib is the best location.

正如 Michael Ransley 提到的,您需要确定谁需要 log4j。如果是web应用,那么WEB-INF/lib是最好的位置。

If it used by EJB components then place the log4j as a utility jar in the EAR.

如果 EJB 组件使用它,则将 log4j 作为实用程序 jar 放置在 EAR 中。

Alternatively, create a Shared Library and associate the shared library to your application.

或者,创建一个共享库并将共享库关联到您的应用程序。

Another choice would be to associate the shared library to your server (instead of the application) in which case, it becomes available to all the applications that are running on that server.

另一种选择是将共享库关联到您的服务器(而不是应用程序),在这种情况下,该服务器上运行的所有应用程序都可以使用它。

Storing in the App Server lib/ext or the other base classpath(s) is usually a bad idea. The reason is this could cause conflicts (log4j does not cause conflicts but other Jars could likely cause conflicts) and might prevent the application server from even starting up.

存储在 App Server lib/ext 或其他基类路径中通常是一个坏主意。原因是这可能会导致冲突(log4j 不会导致冲突,但其他 Jars 可能会导致冲突),甚至可能会阻止应用程序服务器启动。

Also remember, depending on where the log4j.jar is kept (or associated via shared libraries) different class loaders would be picking up this JAR file.

还请记住,根据 log4j.jar 的保存位置(或通过共享库关联)不同的类加载器将获取此 JAR 文件。

回答by user448787

If you have multiple webapps that needs to share the same log4j.xml, you could drop it in IBM\WebSphere\PortalServer\shared\app\\

如果您有多个需要共享同一个 log4j.xml 的 web 应用程序,您可以将它放在 IBM\WebSphere\PortalServer\shared\app\\

Otherwise, put it in web-inf/lib of your web app.

否则,将其放在 Web 应用程序的 web-inf/lib 中。

回答by Mykhaylo Adamovych

PROFILE_ROOT/properties

PROFILE_ROOT/属性

  • this folder is on the classpath, and its used to store properties
  • if you have different profiles for example for test or integration they may have different settings
  • 此文件夹位于类路径上,用于存储属性
  • 如果您有不同的配置文件,例如用于测试或集成,它们可能有不同的设置

source

来源