mybatis 自动生成代码(mybatis generator)
pom.xml 文件配置
引入 mybatis generator
<properties>
<mysql.connector.version>5.1.44</mysql.connector.version>
<mybatis.generator.version>1.3.5</mybatis.generator.version>
<mybatis.spring.version>1.3.1</mybatis.spring.version>
<mybatis.version>3.4.4</mybatis.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>${mybatis.generator.version}</version>
<configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>${mybatis.generator.version}</version>
</dependency>
<dependency>
<groupId>com.github.oceanc</groupId>
<artifactId>mybatis3-generator-plugin</artifactId>
<version>0.4.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
<resources>
<resource>
<!--src/main/java 下的 xml 文件打包时也加入-->
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.*</include>
</includes>
<excludes>
<!--<exclude>test/**/*.*</exclude> -->
</excludes>
</resource>
</resources>
</build>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>自动生成代码的核心配置文件generatorConfig.xml的路径mysql-connector-java生成哪种数据库的代码,不可省略com.github.oceanc引入第三方的jar,能够生成常用的查询语法resources标签配置是为了将mybatis 语法 xml 文件打包进war包,缺少xml文件代码是无法执行的org.mybatis.generator自动生成可执行代码的核心jar,不可缺少
org.mybatis.generator 自带生成代码插件
- org.mybatis.generator.plugins.CachePlugin
二级缓存相关,需要更深入了解一下 - org.mybatis.generator.plugins.CaseInsensitiveLikePlugin
对字符串匹配生成大小写敏感的方法 - org.mybatis.generator.plugins.EqualsHashCodePlugin
重写model中equals和hashCode方法,这对比两个对象的值是否相等很在意义。这个重写可以通过Intellj自带的帮助方法解决,ALT+Insert-->equals() and hashCode()。各处统一使用相同的生成方法即可 - org.mybatis.generator.plugins.FluentBuilderMethodsPlugin
生成withXxx()方法,可以简洁的赋值new MyDomain().withFoo("Test").withBar(4711);。这个功能可以通过Intellj的插件InnerBuilder实现,使用Builder模式。 - org.mybatis.generator.plugins.MapperConfigPlugin
生成MyBatis 3.x框架使用的配置文件。感觉没有什么用处,生成的配置文件也没有生成什么有用的东西 - org.mybatis.generator.plugins.RenameExampleClassPlugin
mybatis默认生成的查询类是以Example结尾,往往都使用如下配置改成Criteria结尾
<plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin">
<property name="searchString" value="Example$" />
<property name="replaceString" value="Criteria" />
</plugin>
- org.mybatis.generator.plugins.RowBoundsPlugin
分页 - org.mybatis.generator.plugins.SerializablePlugin
继承序列化 - org.mybatis.generator.plugins.SqlMapConfigPlugin
生成iBATIS 2.x框架使用的配置文件。感觉没有什么用处,生成的配置文件也没有生成什么有用的东西
<plugin type = "org.mybatis.generator.plugins.SqlMapConfigPlugin">
<property name="fileName" value="test.xml"/>
<property name="targetPackage" value="com.nd.mybatis"/>
<property name="targetProject" value="src/main/java"/>
</plugin>
- org.mybatis.generator.plugins.ToStringPlugin
重写model中toString方法。这个可以通过Intellj完成,ALT+insert-->toString() - org.mybatis.generator.plugins.VirtualPrimaryKeyPlugin
如果表没有主键,mybatis有部分方法不会生成,配置几个虚拟的主键,即使在数据库中并不是主键也可以配置。配置方案
<table tableName="foo">
<property name="virtualKeyColumns" value="ID1, ID2" />
</table>
com.github.oceanc 支持生成代码插件
受sql dialect的限制,多数plugin目前仅支持 Mysql 5.x
Download
在 Maven Central 上最新的发布版本是:
<dependency>
<groupId>com.github.oceanc</groupId>
<artifactId>mybatis3-generator-plugin</artifactId>
<version>0.4.0</version>
</dependency>
mybatis3-generator-plugins目前提供了如下可用插件:
- com.github.oceanc.mybatis3.generator.plugin.BatchInsertPlugin
- com.github.oceanc.mybatis3.generator.plugin.JacksonAnnotationPlugin
- com.github.oceanc.mybatis3.generator.plugin.JacksonToJsonPlugin
- com.github.oceanc.mybatis3.generator.plugin.LombokAnnotationPlugin
- com.github.oceanc.mybatis3.generator.plugin.MinMaxPlugin
- com.github.oceanc.mybatis3.generator.plugin.OptimisticLockAutoIncreasePlugin
- com.github.oceanc.mybatis3.generator.plugin.PaginationPlugin
- com.github.oceanc.mybatis3.generator.plugin.SliceTablePlugin
- com.github.oceanc.mybatis3.generator.plugin.SumSelectivePlugin
- com.github.oceanc.mybatis3.generator.plugin.UpdateSqlTextOfUpdateSelectivePlugin
- com.github.oceanc.mybatis3.generator.plugin.WhereSqlTextPlugin
使用
在MyBatis GeneratorXML Configuration File中添加你需要用到的<plugin>元素:
<context id="MysqlTables" targetRuntime="MyBatis3">
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.BatchInsertPlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.JacksonAnnotationPlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.JacksonToJsonPlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.LombokAnnotationPlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.MinMaxPlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.OptimisticLockAutoIncreasePlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.PaginationPlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.SliceTablePlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.SumSelectivePlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.UpdateSqlTextOfUpdateSelectivePlugin" />
<plugin type = "com.github.oceanc.mybatis3.generator.plugin.WhereSqlTextPlugin" />
</context>
为了举例,假设我们创建一张简单的账户表,并命名为Account。DDL如下:
CREATE TABLE `Account` (
`id` bigint(16) NOT NULL,
`create_time` timestamp NOT NULL,
`name` varchar(64) DEFAULT NULL,
`age` tinyint(3) DEFAULT NULL,
`version` int(11) NOT NULL,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
如果使用了 SliceTablePlugin,为了其产生的作用始终有效,推荐将其放置在自定义 <plugin> 声明的第一条,如上例所示。这么做的原因是,其他 plugin(BatchInsertPlugin、MinMaxPlugin、和SumSelectivePlugin) 会通过检测 SliceTablePlugin 是否应用,来适配其效果。
SliceTablePlugin
当数据库单表数据量过大时,可以通过水平拆分把单表分解为多表。例如,若 Account 表中的预期数据量过大时(也许5、6亿),可以把一张 Account 表分解为多张 Account 表。SliceTablePlugin并不会自动创建和执行拆分后的DDL,因此必须手工创建DDL并按下述约定修改表名。
SliceTablePlugin 目前支持两种分表命名方式:
- 对指定列取模。拆分后的表名为
原表名_N。如:Account_0、Account_1、Account_3 ...... - 对指定的时间类型列,按单自然月拆分。拆分后的表名为
原表名_yyyyMM。如:Account_201501、Account_201502 ...... Account_201512
Xml config
- 利用取模
假如通过Account表的id字段做分表,计划拆分为97张表。在MyBatis GeneratorXML Configuration File 的<table>元素中添加两个<property>
<table tableName="Account_0" domainObjectName="Account">
<property name="sliceMod" value="97"/>
<property name="sliceColumn" value="id"/>
</table>
sliceMod指按取模方式分表,97是取模的模数sliceColumn指取模所使用的列,id是具体列名
- 利用自然月
假如通过Account表的create_time字段做拆分:
<table tableName="Account_0" domainObjectName="Account">
<property name="sliceMonth" value="1"/>
<property name="sliceColumn" value="create_time"/>
</table>
sliceMonth指按自然月分表,1指按单个自然月。Note:目前只支持按单月分表,此处的值 1 无实际意义sliceColumn指时间类型的列,create_time是具体列名
Java sample
- insert
AccountMapper mapper = ...
Account record = new Account();
record.setAge(33);
record.setId(101);
record.setCreateTime(new Date());
mapper.insert(record);
// or mapper.insertSelective(record)
- 通过取模分表时,必须调用
setId并传入合适的参数 - 通过自然月分表时,必须调用
setCreateTime并传入合适的参数
- read
AccountMapper mapper = ...
AccountExample example = new AccountExample();
example.partitionFactorId(id).createCriteria().andAgeEqualTo(33);
// or example.partitionFactorCreateTime(new Date()).createCriteria().andAgeEqualTo(33);
List<Account> as = mapper.selectByExample(example);
- 通过取模分表时,
partitionFactorId方法表示分表因子是Id字段,必须调用该方法并传入合适的参数 - 通过自然月分表时,
partitionFactorCreateTime方法表示分表因子是createTime字段,必须调用该方法并传入合适的参数
- update
AccountMapper mapper = ...
Account record = new Account();
record.setAge(33);
AccountExample example = new AccountExample();
example.partitionFactorId(id).createCriteria().andAgeEqualTo(33);
// or example.partitionFactorCreateTime(new Date()).createCriteria().andAgeEqualTo(33);
mapper.updateByExampleSelective(record, example);
上例的用法和read操作一样,在example对象上必须调用 partitionFactorId 或 partitionFactorCreateTime 方法。
除此之外,还可以用如下方式进行update:
AccountMapper mapper = ...
Account record = new Account();
record.setCreateTime(new Date());
record.setId(101);
// or record.setCreateTime(new Date());
AccountExample example = new AccountExample();
example.createCriteria().andAgeEqualTo(33);
mapper.updateByExampleSelective(record, example);
由于在record对象调用了setId或setCreateTime,就无须在example对象指定分表因子。
- delete
AccountMapper mapper = ...
AccountExample example = new AccountExample();
example.partitionFactorId(id).createCriteria().andAgeEqualTo(33);
// or example.partitionFactorCreateTime(new Date()).createCriteria().andVersionEqualTo(0);
mapper.deleteByExample(example);
- 通过取模分表时,
partitionFactorId方法表示分表因子是Id字段,必须调用该方法并传入合适的参数 - 通过自然月分表时,
partitionFactorCreateTime方法表示分表因子是createTime字段,必须调用该方法并传入合适的参数
- other
当无法获得分表因子的值时、或者确定所操作的表名时,可以通过:
record.setTableNameSuffix(...)取代record.setId(...)或record.setId(...)example.setTableNameSuffix(...)取代example.partitionFactorId(...)
WARNING:由于 setTableNameSuffix 的参数是 String 类型,在 Mybatis3 的 mapper xml 中生成 ${} 变量,这种变量不会做 sql 转义,而直接嵌入到 sql 语句中。如果以用户输入作为 setTableNameSuffix 的参数,会导致潜在的 SQL Injection 攻击,需谨慎使用。
BatchInsertPlugin
该 plugin 是为了增加批量 insert 的功能。特别适用于初始化数据、或迁移数据。
Java sample
AccountMapper mapper = ...
List<Account> as = new ArrayList<>();
as.add(...)
mapper.batchInsert(as);
如果使用了 SliceTablePlugin,则需要对 List 中每一个 Account 实例设置分表因子:
AccountMapper mapper = ...
List<Account> as = new ArrayList<>();
for (Account account : accounts) {
account.setId(...);
// or account.setCreateTime(...);
}
mapper.batchInsert(as);
- 通过取模分表时,必须调用
setId并传入合适的参数 - 通过自然月分表时,必须调用
setCreateTime并传入合适的参数
JacksonAnnotationPlugin
该 plugin 是为生成的 model 类添加jackson的 @JsonProperty、@JsonIgnore、 和 @JsonFormat 注解。若使用此插件,需要额外依赖jackson 2.5 +。(这个插件没有什么必要啊,手工添加更加方便)
Xml config
在MyBatis GeneratorXML Configuration File的 <table> 元素中添加四个 <property>(可选的):
<table tableName="Account_0" domainObjectName="Account">
<property name="jacksonColumns" value="name,age"/>
<property name="jacksonProperties" value="nickName,realAge"/>
<property name="jacksonFormats" value="create_time@yyyy-MM-dd HH:mm:ss"/>
<property name="jacksonIgnores" value="id,version"/>
</table>
jacksonColumns指需要添加@JsonProperty注解的列,由,分割的列名组成。该<property>必须和jacksonProperties成对出现jacksonProperties指@JsonProperty注解所需的参数值,由,分割,这些值的数量和顺序必须和jacksonColumns的值一一对应。该<property>必须和jacksonColumns成对出现jacksonFormats指需要添加@JsonFormat注解的列,值由,分割的键值对组成,键值对由@分割,键为列名,值为@JsonFormat所需参数jacksonIgnores指需要添加@JsonIgnore注解的列,值由,分割的列名组成
Java sample
public class Account implements Serializable {
@JsonIgnore
private Long id;
@JsonProperty("nickName")
private String name;
@JsonProperty("realAge")
private Integer age;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@JsonIgnore
private Long version;
}
JacksonToJsonPlugin
该 plugin 是为生成的 model 类添加 toJson 方法。toJson 方法的实现依赖于jackson。若使用此插件,需要额外依赖jackson 2.5 +。(这个插件没有必要使用,并且会有性能的问题,因为生成的 toJson 方法每次被调用都重新 new ObjectMapper。ObjectMapper 是线程安全的,完全可以做一个全局的变量)
Java sample
public class Account implements Serializable {
public String toJson() throws IOException {
... ...
}
}
LombokAnnotationPlugin
该 plugin 是为生成的 model 类添加lombok注解,避免了 java bean 中繁琐的 setter 和 getter。生成的代码看起来也更干净、紧凑。若使用此插件,需要额外依赖 lombok。(这个插件可用,可不用,因为手工添加几个注解也是简单的)
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.8</version>
</dependency>
Java sample
@Data
public class Account implements Serializable {
private Long id;
... ...
}
MinMaxPlugin
Xml config
在MyBatis GeneratorXML Configuration File 的 <table> 元素中添加两个 <property>(可选的)。(这个支持不好,生成的方法名称不友好,以逗号分隔没有起到作用)
<table tableName="Account_0" domainObjectName="Account">
<property name="minColumns" value="id,version"/>
<property name="maxColumns" value="id,version"/>
</table>
minColumns是可进行min操作的列,值由,分割的列名组成maxColumns是可进行max操作的列,值由,分割的列名组成
Java sample
AccountMapper mapper = ...
AccountExample example = new AccountExample();
example.createCriteria().andAgeEqualTo(33);
long min = mapper.minIdByExample(example);
long max = mapper.maxIdByExample(example);
如果使用了 SliceTablePlugin,别忘了对分表因子赋值:example.partitionFactorCreateTime(...)
OptimisticLockAutoIncreasePlugin
在处理并发写操作时,如果数据竞争较低,通常会采用乐观锁,避免并发问题的同时获得较好的性能。实现乐观锁的一般方式是在数据中添加版本信息,就像 Account 表中的 version 列。当写操作成功时,版本信息也相应递增。该 plugin 就是解决 version 自动递增问题的,可以避免手动对 version+1。
Xml config
在MyBatis GeneratorXML Configuration File的 <table> 元素中添加一个 <property>
<table tableName="Account_0" domainObjectName="Account">
<property name="optimisticLockColumn" value="version"/>
</table>
optimisticLockColumn指具有版本信息语义的列,version是具体的列名
Java sample
AccountMapper mapper = ...
Account record = new Account();
record.setName("tom");
// record.setVersion(1) 无须手工对version进行赋值
AccountExample example = new AccountExample();
example.createCriteria().andAgeEqualTo(33);
mapper.updateByExampleSelective(record, example);
如果使用了 SliceTablePlugin,别忘了对分表因子赋值:example.partitionFactorId(...)
PaginationPlugin
这个与 org.mybatis.generator.plugins.RowBoundsPlugin 的功能是类似的
Java sample
AccountMapper mapper = ...
AccountExample example = new AccountExample();
example.page(0, 2).createCriteria().andAgeEqualTo(33);
List<Account> as = mapper.selectByExample(example);
如果使用了 SliceTablePlugin,别忘了对分表因子赋值:example.partitionFactorCreateTime(...)
SumSelectivePlugin
Java sample
AccountMapper mapper = ...
AccountExample example = new AccountExample();
example.sumAge().createCriteria().andVersionEqualTo(0);
long sum = mapper.sumByExample(example);
如果使用了 SliceTablePlugin ,别忘了对分表因子赋值:example.partitionFactorCreateTime(...)
UpdateSqlTextOfUpdateSelectivePlugin
Java sample
AccountMapper mapper = ...
Account record = new Account();
record.setUpdateSql("version = version + 1")
record.setAge(33);
AccountExample example = new AccountExample();
example.createCriteria().andAgeEqualTo(22);
mapper.updateByExampleSelective(record.setAge, example);
如果使用了 SliceTablePlugin,别忘了对分表因子赋值:example.partitionFactorCreateTime(...)
WARNING:由于 setUpdateSql 的参数是 String 类型,在 Mybatis3 的 mapper xml 中生成 ${} 变量,这种变量不会做 sql 转义,而直接嵌入到 sql 语句中。如果以用户输入作为 setUpdateSql 的参数,会导致潜在的 SQL Injection 攻击,需谨慎使用。
WhereSqlTextPlugin
Java sample
AccountMapper mapper = ...
int v = 1;
AccountExample example = new AccountExample();
example.createCriteria().andAgeEqualTo(33).addConditionSql("version =" + v + " + 1");
List<Account> as = mapper.selectByExample(example);
如果使用了 SliceTablePlugin,别忘了对分表因子赋值:example.partitionFactorCreateTime(...)
WARNING:由于 setUpdateSql 的参数是 String 类型,在 Mybatis3 的 mapper xml 中生成 ${} 变量,这种变量不会做 sql 转义,而直接嵌入到 sql 语句中。如果以用户输入作为 setUpdateSql 的参数,会导致潜在的 SQL Injection 攻击,需谨慎使用。
本篇博客主要来自:https://github.com/oceanc/mybatis3-generator-plugins,其他部分内容来自官网:http://www.mybatis.org/generator/reference/plugins.html
mybatis 自动生成代码(mybatis generator)的更多相关文章
- 【MyBatis】MyBatis自动生成代码查询之爬坑记
前言 项目使用SSM框架搭建Web后台服务,前台后使用restful api,后台使用MyBatisGenerator自动生成代码,在前台使用关键字进行查询时,遇到了一些很宝贵的坑,现记录如下.为展示 ...
- Mybatis 自动生成代码,数据库postgresql
最近做了一个项目,使用Mybatis自动生成代码,下面做一下总结,被以后参考: 一.提前准备: 1.工具类:mybatis-generator-core-1.3.2.jar 2.postgresql驱 ...
- mybatis自动生成代码插件mybatis-generator使用流程(亲测可用)
mybatis-generator是一款在使用mybatis框架时,自动生成model,dao和mapper的工具,很大程度上减少了业务开发人员的手动编码时间 坐着在idea上用maven构建spri ...
- MyBatis自动生成代码示例
在项目中使用到mybatis时,都会选择自动生成实体类,Mapper,SqlMap这三个东东. 手头上在用的又不方便,找了下网上,其实有很多文章,但有些引用外部文件时不成功,也不方便,所以重新整理了下 ...
- springboot mybatis 自动生成代码(maven+IntelliJ IDEA)
1.在pom文件中加入需要的依赖(mybatis-generator-core) 和 插件(mybatis-generator-maven-plugin) <dependency> < ...
- mybatis自动生成代码工具(逆向工程)
MyBatis自动生成实体类(逆向工程) MyBatis属于一种半自动的ORM框架,它需要我们自己编写sql语句和映射文件,但是编写映射文件和sql语句很容易出错,所以mybatis官方提供了Gene ...
- 自定义Mybatis自动生成代码规则
前言 大家都清楚mybatis-generate-core 这个工程提供了获取表信息到生成model.dao.xml这三层代码的一个实现,但是这往往有一个痛点,比如需求来了,某个表需要增加字段,肯定需 ...
- Mybatis自动生成代码,MyBatis Generator
这还是在学校里跟老师学到的办法,然后随便在csdn下载一个并调试到可以用的状态. 基本由这几个文件组成,一个mysql连接的jar包.一个用于自动生成的配置文件,一个自动生成的jar包,运行jar包语 ...
- mybatis自动生成代码
使用maven集成mybatis-generator插件生成Mybatis的实体类,DAO接口和Map映射文件 本例中,使用的是mysql数据库 前提:表已经建好 mybatis框架的jar包,数据 ...
随机推荐
- 【Win10】zip安装MySQL
1. mysqld初始化时my.ini的第二个默认位置是%windir%/my.ini rem 1.查看此变量对应的目录,在此目录下编辑 my.ini,mysqld会自动找到 echo %WINDIR ...
- 【Js应用实例】限制上传图片大小
需求:前端页面开发中,常遇到图片上传的需求,一般要求限制图片格式及大小. 说明:这里就把实现此功能所需代码贴出来,供同志们参考,也方便我以后复用. 要点:1.处理 类型type为file的输入元素的v ...
- 8.2.1 UML, 组合和聚合、关联和依赖
类A的属性是另一个类B,那么这两个类是关联的,但不一定是聚合,如果在A类中创建了B类的实例(使用new!),那么B类和A类就是聚合关系,但不一定是组合关系,因为不一定在A类创建的同时去创建B类的实例, ...
- 7.21.06 java内存模型
资料来源:http://www.cnblogs.com/smile361/archive/2013/11/25/3441553.html 程序计数器: 当前线程所执行的字节码的行号指示器 本地方法栈: ...
- java创建目录与文件
java创建目录与文件: package com.led.file; import java.io.File; import java.io.IOException; public class Fil ...
- idea 远程调试
Idea 远程在线测试 描述:在window下开发,部署到Linux服务器上,往往会遇到在windows下正常运行,在Linux服务器下异常,这是需要本地调试远程代码: 操作步骤: 一.代码已知 保证 ...
- 使用ASP.NET Core MVC 和 Entity Framework Core 开发一个CRUD(增删改查)的应用程序
使用ASP.NET Core MVC 和 Entity Framework Core 开发一个CRUD(增删改查)的应用程序 不定时更新翻译系列,此系列更新毫无时间规律,文笔菜翻译菜求各位看官老爷们轻 ...
- MySQL整数类型说明 int(5) vs int(7)
今天突然发现, mysql 中int(1)和tinyint(1)中的1只是指定显示长度,并不表示存储长度,只有字段指定zerofill时有用.位数限制基本没有意义. int(5) 这里的5表示的是 最 ...
- TCP/IP协议栈模型
OSI七层模型介绍: 下面4层(物理层.数据链路层.网络层和传输层)主要提供数据传输和交换功能,即以节点到节点之间的通信为主:第4层作为上下两部分的桥梁,是整个网络体系结构中最关键的部分:而上3层(会 ...
- Cython的用法以及填坑姿势
因为项目需要,需要优化已有的Python代码.目前Python代码的执行过程是将Python代码转变成一行行指令,然后解释器解释指令的执行,调用到C代码层.如果去掉指令解释这个阶段,直接进入C代码层, ...