1. Sort plugin
In a previous attempt to introduce interceptors in the pagination plug-in package, in fact, we have a better mybatis pagination plug PageHelper, specific usage:
1. Package guide
2. Registration interceptor
3. Write mapper
4. Call
The results are as follows:
The results pageInfo data analysis:
There are many attributes, you can test your own specific
2. The automatic code generation
Automatic code generation can help us generate entity classes, mapper mapping a dao interface files, reducing the amount of code, use:
1. Package guide:
2. Edit the configuration file, the location of the configuration file must be consistent with the position of the configuration above:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <!-- 数据库驱动包位置 --> <classPathEntry location="D:\work\mysql\mysql-connector-java\5.1.45\mysql-connector-java-5.1.45.jar"/> <context id="mysql" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressDate" value="true"/> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true"/> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password="123456"> </jdbcConnection> <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer,为 true时把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false"/> </javaTypeResolver> <!--生成实体类--> <javaModelGenerator targetPackage="com.zs.entity" targetProject="src/main/java"> <property name="enableSubPackages" value="true"/> <property name="trimStrings" value="true"/> </javaModelGenerator> <!--生成映射文件--> <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources"> <property name="enableSubPackages" value="true"/> </sqlMapGenerator> <!--生成mapper文件对应的dao--> <javaClientGenerator type="XMLMAPPER" targetPackage="com.zs.dao" targetProject="src/main/java"> <property name="enableSubPackages" value="true"/> </javaClientGenerator> <!--配置表信息--> <table tableName="emp" domainObjectName="Emp" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> <table tableName="dept" domainObjectName="Dept" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/> </context> </generatorConfiguration>
3.生成代码:
点击后就可以自动生成代码了