Distribution Manifest.mf 中的单个点 (“.”) 是什么意思?

发布于 2024-10-16 06:25:10 字数 892 浏览 4 评论 0原文

最近我对 Manifest.mf 文件中的类路径有点困惑。所以我想要的是将一些properties.files从我的distribution.jar中外包出来,并将它们放在它旁边,而不更改java-source-files。

以下示例: 此时我可以打开这样的属性文件:

this.getClass().getClassLoader().getRessourceAsStream( "/config/jdbc.properties" );

jdbc.properties 位于名为“resources”的 eclipse 源文件夹中,其中包含一个名为“config”的包。现在,当我构建发行版时,我将它们外包到 distribution.jar 旁边的文件夹中,但如果不更改显示的源代码,我仍然无法找到它们。

到目前为止唯一有效的通用解决方案(没有绝对路径)是以下manifest.mf:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 17.1-b03 (Sun Microsystems Inc.)
Main-Class: com.ymene.Main
Class-Path: .

“。” Class-Path 中似乎指向 .jar 的根目录?我以前从未在任何清单文件中见过这样的情况。所以我想知道,这是否是实现我完全不更改 java 源代码的愿望的正确方法,无论资源是在 jar 内部还是外部构建,只要路径相同即可。

谁能告诉我,如果“。”在manifest.fm文件中会对我产生任何不良的副作用吗?如果情况并非如此,是否可以使用 Ant 生成 Manifest.mf 类路径条目(我的意思是“.”)?或者还有其他解决方案可以实现这一目标吗?

预先感谢您对此主题的任何帮助, 伊梅内

lately I got a bit confused concerning class-pathes in Manifest.mf-files. So what I want is to outsource some properties.files out of my distribution.jar and put them next to it without changing java-source-files.

Following example: At this time I can open a properties-file like this:

this.getClass().getClassLoader().getRessourceAsStream( "/config/jdbc.properties" );

The jdbc.properties are located in an eclipse sourcefolder called 'resources' with a package named 'config'. Now when I build the distribution I outsource them in a folder next to the distribution.jar, but I still wonna find them without changing the shown sourcecode.

Only generell solution which worked until now (without absolout pathes) was the following manifest.mf:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.1
Created-By: 17.1-b03 (Sun Microsystems Inc.)
Main-Class: com.ymene.Main
Class-Path: .

The "." in Class-Path seems to point on the root of the .jar? I`ve never seen it like that before in any manifest files. So I wonder, if that is the right approach to achieve my wish to not change my java-sourcecode at all, no matter if the resource will be builded within or outside the jar as long as the path will be the same.

Can anyone tell me, if the "." in the manifest.fm file will have any undesired side effects for me? And if that wont be the case, is it possible to generate that Manifest.mf Class-Path entry (the "." i mean) with Ant? Or is there any other solution to achieve that?

Thanks in advance for any help on this topic,
ymene

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弄潮 2024-10-23 06:25:10

单点表示“此目录”。

The single dot means "this directory".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文