Eclipse+MyBatis自动生成Mapper和实体还有对应sqlxml

1.安装插件(eclipse的marketplace中搜索mybatis就行了)

Eclipse+MyBatis自动生成Mapper和实体还有对应sqlxml_第1张图片

2.创建generatorConfig.xml文件(配置数据库等信息,读懂这个文件的内容就行了)

Eclipse+MyBatis自动生成Mapper和实体还有对应sqlxml_第2张图片

generatorConfig.xml文件



<generatorConfiguration>
    <classPathEntry location="E:/jar/mysql-connector-java-5.1.25.jar" />
    <context id="context1">
        
        <plugin type="org.mybatis.generator.plugins.SerializablePlugin">plugin>
        <commentGenerator>
            
            <property name="suppressAllComments" value="true" />
        commentGenerator>
        <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3306/hongbaodb?characterEncoding=utf8" userId="kevinLee" password="1234" />
        <javaModelGenerator targetPackage="com.ithaha.pojo" targetProject="redpacket" />
        <sqlMapGenerator targetPackage="com.ithaha.mapper" targetProject="redpacket" />
        <javaClientGenerator targetPackage="com.ithaha.mapper" targetProject="redpacket" type="XMLMAPPER" />
        <table schema="RedPacket" tableName="t_red_packet" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" domainObjectName="RedPacket">table>
        <table schema="UserRedPacket" tableName="t_user_red_packet" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" domainObjectName="UserRedPacket">table>
    context>
generatorConfiguration>

3.生成对应实体类和mapper文件

Eclipse+MyBatis自动生成Mapper和实体还有对应sqlxml_第3张图片

你可能感兴趣的:(问题解决)