我可以理解,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/