此内容没有您所选择的语言版本。

11.2. Class Sharing


Private class space

By default, a FAB adds each Maven dependency to its private class space at run time (except for dependencies having Maven group ID org.apache.camel, org.apache.activemq, or org.apache.cxf, which are shared by default). This is a safe approach to deploying dependencies, because it reduces the risk of version inconsistencies. But it is also an expensive approach, in terms of resources, because it forces the JVM to maintain a dedicated copy of each dependency in memory, just for this FAB.

Shared class space

You can make a FAB more economical by opting to share some of its dependencies with other applications in the container. There are two approaches you can use:

Specify shared dependencies using provided scope

To share a dependency (and its transitive dependencies), declare a dependency with the provided scope in your project's pom.xml file. For example:
<dependency>
  <groupId>org.acme.foo</groupId>
  <artifactId>foo-core</artifactId>
  <version>${foo-version}</version>
 <scope>provided</scope>
</dependency>
Copy to Clipboard Toggle word wrap
This is analogous to the approach you would use when building a WAR with Maven, in order to avoid including libraries like the servlet API or the JSP API.

Specify shared dependencies using Manifest header

You can also configure class sharing by setting the FAB-Provided-Dependency: manifest header. For example, to share all artifacts with the org.acme.foo Maven group ID:
FAB-Provided-Dependency: org.acme.foo:* org.apache.camel:* org.apache.cxf:* org.apache.activemq:*
Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat