基於mybatis-generator-core 1.3.5項目的修訂版以及源碼剖析,mybatisgeneratorcore

來源:互聯網
上載者:User

基於mybatis-generator-core 1.3.5項目的修訂版以及源碼剖析,mybatisgeneratorcore
項目簡單說明

mybatis-generator,是根據資料庫表、欄位反向產生實體類等代碼檔案。我在國慶時候,沒事剖析了mybatis-generator-core源碼,寫了相當詳細的中文注釋,可以去看看。目前我剖析修改的是1.3.5版本。

 

源碼剖析說明

1.剖析org.mybatis.generator.plugins.ToStringPlugin源碼
2.剖析org.mybatis.generator.plugins.MapperConfigPlugin源碼
3.剖析org.mybatis.generator.api.ShellRunner源碼,Main入口
3.剖析org.mybatis.generator.config.xml.ConfigurationParser源碼,配置解析器,用於對generatorConfig.xml設定檔的解析
4.剖析org.mybatis.generator.config.Context源碼,封裝元素內容

修改源碼說明(原版本沒有的功能)

1.資料表的備忘資訊的添加:在FullyQualifiedTable類中添加remark欄位,並在org.mybatis.generator.internal.db.DatabaseIntrospector類calculateIntrospectedTables方法,添加一段擷取資料庫備忘的代碼

 1   //設定資料庫表的備忘資訊 2   //start 3   Statement stmt = this.databaseMetaData.getConnection().createStatement(); 4   ResultSet rs = stmt.executeQuery( 5           new StringBuilder() 6           .append("SHOW TABLE STATUS LIKE '") 7           .append(atn.getTableName()) 8           .append("'") 9           .toString());10   while (rs.next())11       table.setRemark(rs.getString("COMMENT"));12   closeResultSet(rs);13   stmt.close();14   //end


2..非model類Example的注釋方法的添加,方法名addExampleClassComment(TopLevelClass topLevelClass)
3.重構部分org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3Impl包裡getGeneratedJavaFiles方法
4.詳細中文注釋的添加,入口包函數在org.mybatis.generator.api.ShellRunner
5.產生的中文注釋資訊可在修DefaultCommentGenerator類修改

 

源碼地址:https://github.com/orange1438/mybatis-generator-core-chinese-annotation-1.3.5

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.