Modify third-party source code and repackage

1. In many scenarios
, it is necessary to download third-party source code to modify and recompile and package. For example, mybatis-generator-core-1.3.2.jar needs to modify org.mybatis.generator.internal.DefaultCommentGenerator.java.

2. Step
2.1 Extract the source code and modify
it. We can decompile the source code from the jar package (which may be inconsistent with the source code). It is best to extract the source code from the source package (mvn download), and then modify it.

2.2 Compile
Put the class jar package mybatis-generator-core-1.3.2.jar in the E:\git_other directory, extract mybatis-generator-core-1.3.2-sources.jar to the current directory, mybatis-generator -core-1.3.2-sources.
Then go to the directory of the modified source file and execute it under cmd:
E:\git_other\mybatis-generator-core-1.3.2-sources\org\mybatis\generator\internal>javac -encoding utf8 -source 1.6 -target 1.6 -classpath E:\git_other\mybatis-generator-core-1.3.2.jar DefaultCommentGenerator.java

compiled successfully.
Then replace the modified class file with mybatis-generator-core-1.3.2.jar (try 7zip).

Supplementary note, if there are multiple files to be modified, please execute them in the order of dependencies.

For mybatis-generator:
DefaultCommentGenerator.java: model, the default comment of xml is generated here
DefaultDAOMethodNameCalculator.java: The default method name of mapper is generated here
IntrospectedTable.java: The default id of xml is generated here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326421170&siteId=291194637