Mybatis自动生成Dao,Mapper,entity

mybatis-generator.xml

 
<generatorConfiguration>
    <context id="DB2Tables" targetRuntime="MyBatis3Simple">
        <commentGenerator>
            <property name="suppressDate" value="true" />
            
            
            <property name="suppressAllComments" value="true" />
        commentGenerator>
        
        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/ruralrevitalization?characterEncoding=utf-8"
                        userId="root" password="root">
        jdbcConnection>
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false" />
        javaTypeResolver>
        
        <javaModelGenerator targetPackage="com.HL.entity"
                            targetProject=".\src\main\java">
            <property name="enableSubPackages" value="true" />
            <property name="trimStrings" value="true" />
        javaModelGenerator>
        
        <sqlMapGenerator targetPackage="\SqlMappper"
                         targetProject=".\src\main\resources">
            <property name="enableSubPackages" value="true" />
        sqlMapGenerator>
        
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="com.HL.dao" targetProject=".\src\main\java">
            <property name="enableSubPackages" value="true" />
        javaClientGenerator>
        
        <table tableName="%"
               enableCountByExample="false"
               enableUpdateByExample="false"
               enableDeleteByExample="false"
               enableSelectByExample="false"
               selectByExampleQueryId="false" >
        table>

    context>
generatorConfiguration>

pom.xml

<dependencies>
                
                <dependency>
                    <groupId>org.mybatis.generatorgroupId>
                    <artifactId>mybatis-generator-coreartifactId>
                    <version>1.3.5version>
                dependency>
            dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.mybatis.generatorgroupId>
                <artifactId>mybatis-generator-maven-pluginartifactId>
                <version>1.3.5version>
                <configuration>
                    <overwrite>falseoverwrite>
                    <configurationFile>src/main/resources/mybatis-generator.xmlconfigurationFile>
                configuration>
                <dependencies>
                    
                    <dependency>
                        <groupId>mysqlgroupId>
                        <artifactId>mysql-connector-javaartifactId>
                        <version>5.1.49version>
                    dependency>
                dependencies>
            plugin>
        plugins>
    build>

Mybatis自动生成Dao,Mapper,entity_第1张图片

双击该插件即可生成!

你可能感兴趣的:(Java,Web)