Eclipse中mybatis自动生成代码

工具下载

  1. Eclipse中help–>install new software
  2. 如下图所示
    Eclipse中mybatis自动生成代码_第1张图片
    Location:内容
  3. 完成安装之后,选择新建–Ctrl + N之后,生成generateConfig.xml文件

GenerateConfig.xml文件

  1. 配置GenerateConfig.xml文件


<generatorConfiguration>

    <classPathEntry
        location="C:\Users\baiju\.m2\repository\mysql\mysql-connector-java\5.1.30\mysql-connector-java-5.1.30.jar" />
    <context id="context1">
        
        <commentGenerator>
            <property name="suppressAllComments" value="true" />
            <property name="suppressDate" value="true" />
        commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql:///mybatis" userId="root" password="920512" />
        
        <javaModelGenerator targetPackage="com.future.study.domain"
            targetProject="future/java">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        javaModelGenerator>
        
        <sqlMapGenerator targetPackage="test.mapping"
            targetProject="future/java">
            <property name="enableSubPackages" value="true" />
        sqlMapGenerator>
        
        <javaClientGenerator type="XMLMAPPER"
            targetPackage="com.future.study.mapper" targetProject="future/java">
            <property name="enableSubPackages" value="true" />
        javaClientGenerator>
        

        <table tableName="classinfo" domainObjectName="ClassInfo"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="course" domainObjectName="Course"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="department" domainObjectName="Department"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="namingrecord" domainObjectName="NamingRecord"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="student" domainObjectName="Student"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="supermin" domainObjectName="SuperAdmin"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="teacher" domainObjectName="Teacher"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="teacherclass" domainObjectName="TeacherClass"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
        <table tableName="teachercourse" domainObjectName="TeacherCourse"
            enableCountByExample="false" enableUpdateByExample="false"
            enableDeleteByExample="false" enableSelectByExample="false"
            selectByExampleQueryId="false">table>
    context>
generatorConfiguration>  
  1. 在Eclipse中鼠标右键选中 generateConfig.xml文件,选择 Generate Mybatis/iBATIS Artifacts

你可能感兴趣的:(工具使用)