MyBatis로 탭 플러그, 자동 코드 생성 위젯

1. 정렬 플러그인

페이지 매김 플러그인 패키지에 인터셉터를 소개하는 이전 시도에서, 사실, 우리는 특정 사용 더 나은 MyBatis로 매김 플러그 PageHelper 있습니다 :

1. 패키지 가이드

2. 등록 인터셉터

3. 쓰기 매퍼

4. 전화

결과는 다음과 같다 :

데이터 분석 결과 pageInfo :

많은 속성이있다, 당신은 당신의 자신의 특정을 테스트 할 수 있습니다

 2. 자동 코드 생성

자동 코드 생성 매퍼하는 DAO 인터페이스 파일을 매핑 코드의 양을 줄이고, 우리는 엔티티 클래스를 생성 할 수 있습니다, 사용 :

1. 패키지 가이드 :

2. 편집 구성 파일, 구성 파일의 위치는 위의 구성의 위치와 일치해야합니다 :

<?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.生成代码:

点击后就可以自动生成代码了

 

추천

출처www.cnblogs.com/Zs-book1/p/11281451.html