jar中META-INF

Posted 太白的技术博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jar中META-INF相关的知识,希望对你有一定的参考价值。

一直记得META-INF中只有在直接启动jar可执行文件时需要在manifest中配置启动类,最近看dubbo的配置,发现dubbo的配置都丢在META-INF下,特地搜索了下,官网对于META-INF的说明如下:

The META-INF directory

The following files/directories in the META-INF directory are recognized and interpreted by the Java 2 Platform to configure applications, extensions, class loaders and services:

  • MANIFEST.MF

The manifest file that is used to define extension and package related data.

  • INDEX.LIST

This file is generated by the new "-i" option of the jar tool, which contains location information for packages defined in an application or extension.  It is part of the JarIndex implementation and used by class loaders to speed up their class loading process.

  • x.SF

The signature file for the JAR file.  ‘x‘ stands for the base file name.

  • x.DSA

The signature block file associated with the signature file with the same base file name. This file stores the digital signature of the corresponding signature file.

  • services/

This directory stores all the service provider configuration files.

一般来说,META-INF下不会存储和应用配置相关的信息。而且可以认为是Java自己的元数据目录。其他应用配置,应该放在其他目录比如conf。

以上是关于jar中META-INF的主要内容,如果未能解决你的问题,请参考以下文章

从 JAR 中读取 META-INF/MANIFEST.MF [重复]

Intellij Idea生成含有META-INF的jar包

使用 Gradle 的 JAR 中的 META-INF/服务

JAR包结构,META-INF/MANIFEST.MF文件详细说明[全部属性][打包][JDK]

META-INF文件夹可以删除吗(急)

Jar文件 META-INF/MANIFEST.MF文件详解