修改mybatis-generator-gui生成的代码
本想改 mybatis-generator-gui Java代码,但是看到要修改的部分是在一个jar包中
改jar包的话得找到源码,修改后重新打包,觉得好麻烦
就选择了使用bat二次操作
@echo off :: 插入andOther for /r %%i in (*Example.java) do ( call %~dp0JavaOther.bat %%~fi ) :: 插入inset for /r %%i in (*.xml) do ( call %~dp0XmlInsert.bat %%~fi ) :: 复制xml for /r %%i in (*.xml) do ( copy "%%~fi" %%~niExtend.xml )
@echo off setlocal enabledelayedexpansion :: 等号两边不能有空格 :: 变量是变量得用惊叹号 :: /a用于变量数字计算 set "Str01= public Criteria andOther(String condition, Object value) {" set "Str02= addCriterion(condition, value, condition);" set "Str03= return (Criteria) this;" set "Str04= }" set XmlFile="%1" echo %XmlFile% for /f "tokens=1* delims=:" %%i in ('findstr /i /n /c:"class Criteria" %XmlFile%') do ( echo %%i set /a HangHao=%%i+3 echo !HangHao! ) (for /f "tokens=1* delims=:" %%i in ('findstr /n . %XmlFile%') do ( echo %%j if %%i equ !HangHao! echo !Str01! & echo !Str02! & echo !Str03! & echo !Str04! )) > lcx.txt move lcx.txt %XmlFile% pause
@echo off setlocal enabledelayedexpansion :: 等号两边不能有空格 :: 变量是变量得用惊叹号 set "Str01= <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">" set "Str02= SELECT LAST_INSERT_ID()" set "Str03= </selectKey>" set XmlFile="%1" echo %XmlFile% for /f "tokens=1* delims=:" %%i in ('findstr /i /n "id=\"insert\"" %XmlFile%') do ( echo %%i set HangHao=%%i echo !HangHao! ) (for /f "tokens=1* delims=:" %%i in ('findstr /n . %XmlFile%') do ( echo %%j if %%i equ !HangHao! echo !Str01! & echo !Str02! & echo !Str03! )) > lcx.txt move lcx.txt %XmlFile% pause
不得不说 findstr 真的是一个很棒的命令