编程知识 cdmana.com

Maven ~ for MANIFEST.MF File add content

MANIFEST.MF

open Java Of JAR File we can often see that there is a META-INF Catalog , There will be some files in this directory , There must be one MANIFEST.MF, This document describes the Jar A lot of information about the file , More on this below MANIFEST.MF The content of the document .

Public content

  1. Manifest-Version Used to define manifest Version of a file , for example :Manifest-Version: 1.0
  2. Created-By Declare the producer of the file , In general, this attribute is created by jar Command line tool generated , for example :Created-By: Apache Ant 1.5.1
  3. Signature-Version Definition jar Signed version of the document
  4. Class-Path The application or class loader uses this value to build the internal class search path
  5. Main-Class Definition jar File entry class , This class must be an executable class , Once the attribute is defined, it can be passed through java -jar x.jar To run the jar file .

javaagent Parameter properties

  1. Premain-Class: com.lind.hot.deploy.DemoJavaAgent It is equivalent to , When we put this jar treat as -javaagent Parameter to register the current class loader , That is, if you want to be a javaagent package , You need to add this property

DemoJavaAgent Content

Be careful :javaagent The implementation of is in the current project main Method , So it's always used in Project hot deployment Project encryption And other scenarios .

public class DemoJavaAgent {
    /**
     *  The method in main Method before running , And main Methods run on the same JVM in 
     *  And by the same System ClassLoader load 
     *  Unified security policy (security policy) And context (context) management 
     *
     * @param agentOps
     * @param inst
     * @author SHANHY
     * @create 2016 year 3 month 30 Japan 
     */
    public static void premain(String agentOps, Instrumentation inst) {

        System.out.println("====premain  Method execution ");
        System.out.println(agentOps);
    }

    /**
     *  If it doesn't exist  premain(String agentOps, Instrumentation inst)
     *  Will perform  premain(String agentOps)
     *
     * @param agentOps
     * @author SHANHY
     * @create 2016 year 3 month 30 Japan 
     */
    public static void premain(String agentOps) {

        System.out.println("====premain Method execution 2====");
        System.out.println(agentOps);
    }

版权声明
本文为[Zhang Zhanling]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224091951895n.html

Scroll to Top