java - 为什么 Java EJB 应用程序没有为其库预定义相对路径?

标签 java ejb classpath appserver

我可以理解,Java 中的桌面应用程序没有用于包含 jar(库)文件的预定义相对路径。它已经有一个 CLASS_PATH 环境变量。

但是我无法理解为什么 EJB 模块没有这样的功能...(Web App 有!- throw WEB-INF/lib)

最佳答案

以下是 Java EE 规范的两段摘录:

A JAR format file (such as a .jar file, .war file, or .rar file) may reference a .jar file or directory by naming the referenced .jar file or directory in a Class-Path header in the referencing JAR file’s Manifest file. The referenced .jar file or directory is named using a URL relative to the URL of the referencing JAR file. The Manifest file is named META-INF/MANIFEST.MF in the JAR file. The Class-Path entry in the Manifest file is of the form

Class-Path: list-of-jar-files-or-directories-separated-by-spaces

A .ear file may contain a directory that contains libraries packaged in JAR files. The library-directory element of the .ear file’s deployment descriptor contains the name of this directory. If a library-directory element isn’t specified, or if the .ear file does not contain a deployment descriptor, the directory named lib is used. An empty library-directory element may be used to specify that there is no library directory. All files in this directory (but not subdirectories) with a .jar extension must be made available to all components packaged in the EAR file, including application clients. These libraries may reference other libraries, either bundled with the application or installed separately, using any of the techniques described herein.

关于java - 为什么 Java EJB 应用程序没有为其库预定义相对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11224107/

相关文章:

java - 如何使用 SpringBoot Security 禁用 OPTIONS 的基本 http 身份验证

java - 无法将 SurfaceTexture 设置为已发布的 SurfaceTexture

java - 如何引用Hadoop上hdfs中存储的依赖项(jar)?

classpath - 如何在 OSGi Bundle 中创建/初始化 Javassist ClassPool?

java - RESTFul Webservice 注释中的问题

java - 添加我的数据源后将项目添加到 selectItem

java - GSON新手: parse a JSON string into into a double[] ref

java - JBoss MQ教程

java - 为什么抛出EJBException是 "recommended"的做法?

java - 将 Pojo 组件转换为 EJB3