zoukankan      html  css  js  c++  java
  • MBG

    1. 导入相关包
    2. <!--数据库连接-->  
    3.     <dependency>  
    4.         <groupId>mysql</groupId>  
    5.         <artifactId>mysql-connector-java</artifactId>  
    6.         <version>5.1.41</version>  
    7.     </dependency>  
    8.     <dependency>  
    9.         <groupId>com.alibaba</groupId>  
    10.         <artifactId>druid</artifactId>  
    11.         <version>1.1.3</version>  
    12.     </dependency>  
    13.     <!--MyBatis-->  
    14.     <dependency>  
    15.         <groupId>org.mybatis.spring.boot</groupId>  
    16.         <artifactId>mybatis-spring-boot-starter</artifactId>  
    17.         <version>1.3.1</version>  
    18.     </dependency>  

    2. 导入插件

    1. <plugin>  
    2.     <groupId>org.mybatis.generator</groupId>  
    3.     <artifactId>mybatis-generator-maven-plugin</artifactId>  
    4.     <version>1.3.5</version>  
    5.     <dependencies>  
    6.         <dependency>  
    7.             <groupId>org.mybatis.generator</groupId>  
    8.             <artifactId>mybatis-generator-core</artifactId>  
    9.             <version>1.3.5</version>  
    10.         </dependency>  
    11.         <dependency>  
    12.             <groupId>mysql</groupId>  
    13.             <artifactId>mysql-connector-java</artifactId>  
    14.             <version>5.1.41</version>  
    15.         </dependency>  
    16.     </dependencies>  
    17.     <executions>  
    18.         <execution>  
    19.             <id>mybatis generator</id>  
    20.             <phase>package</phase>  
    21.             <goals>  
    22.                 <goal>generate</goal>  
    23.             </goals>  
    24.         </execution>  
    25.     </executions>  
    26.     <configuration>  
    27.         <!-- 允许移动生成的文件 -->  
    28.         <verbose>false</verbose>  
    29.         <!-- 允许自动覆盖文件 -->  
    30.         <overwrite>false</overwrite>  
    31.         <configurationFile>  
    32.             src/main/resources/mybatis-generator.xml  
    33.         </configurationFile>  
    34.     </configuration>  
    35. </plugin>  

    3. 创建对应包, 在resources文件下创建mybatis-generator.xml

    1. <?xml version="1.0" encoding="UTF-8"?>  
    2. <!DOCTYPE generatorConfiguration  
    3.         PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"  
    4.         "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">  
    5.     
    6. <generatorConfiguration>  
    7.     
    8.     <context id="default" targetRuntime="MyBatis3">  
    9.     
    10.         <!-- optional,旨在创建class时,对注释进行控制 -->  
    11.         <commentGenerator>  
    12.             <property name="suppressDate" value="true"/>  
    13.             <property name="suppressAllComments" value="true"/>  
    14.         </commentGenerator>  
    15.     
    16.         <!--jdbc的数据库连接 -->  
    17.         <jdbcConnection driverClass="com.mysql.jdbc.Driver"  
    18.                         connectionURL="jdbc:mysql://127.0.0.1:3306/xunwu"  
    19.                         userId="root"  
    20.                         password="123456">  
    21.         </jdbcConnection>  
    22.     
    23.     
    24.         <!-- 非必需,类型处理器,在数据库类型和java类型之间的转换控制-->  
    25.         <javaTypeResolver>  
    26.             <property name="forceBigDecimals" value="false"/>  
    27.         </javaTypeResolver>  
    28.     
    29.         <!-- 生成DataObject类存放位置 -->  
    30.         <javaModelGenerator targetPackage="com.figsprite.xunwu.dataobject" targetProject="src/main/java">  
    31.             <!-- 是否允许子包,即targetPackage.schemaName.tableName -->  
    32.             <property name="enableSubPackages" value="false"/>  
    33.             <!-- 是否对DO添加 构造函数 -->  
    34.             <property name="constructorBased" value="true"/>  
    35.             <!-- 是否对类CHAR类型的列的数据进行trim操作 -->  
    36.             <property name="trimStrings" value="true"/>  
    37.             <!-- 建立的DO对象是否 不可改变  即生成的Model对象不会有 setter方法,只有构造方法 -->  
    38.             <property name="immutable" value="false"/>  
    39.         </javaModelGenerator>  
    40.         <!-- 生成映射文件存放位置 -->  
    41.         <sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources">  
    42.             <property name="enableSubPackages" value="false"/>  
    43.         </sqlMapGenerator>  
    44.     
    45.         <!-- 生成Dao类存放位置 -->  
    46.         <!-- 客户端代码,生成易于使用的针对Model对象和XML配置文件的代码  
    47.               type="ANNOTATIONDMAPPER",生成Java Model和基于注解的Mapper 对象  
    48.               type="MIXEDMAPPER",生成基于注解的Java Model和相应的Mapper对象  
    49.               type="XMLMAPPER",生成SQLMap XML 文件和独立的Mapper接口-->  
    50.         <javaClientGenerator type="XMLMAPPER" targetPackage="com.figsprite.xunwu.dao" targetProject="src/main/java">  
    51.             <property name="enableSubPackages" value="true"/>  
    52.         </javaClientGenerator>  
    53.     
    54.     
    55.         <table tableName="house" domainObjectName="House" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    56.         <table tableName="house_detail" domainObjectName="HouseDetail" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    57.         <table tableName="house_picture" domainObjectName="HousePicture" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    58.         <table tableName="house_subscribe" domainObjectName="HouseSubscribe" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    59.         <table tableName="house_tag" domainObjectName="HouseTag" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    60.         <table tableName="role" domainObjectName="Role" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    61.         <table tableName="subway" domainObjectName="Subway" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    62.         <table tableName="subway_station" domainObjectName="SubwayStation" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    63.         <table tableName="support_address" domainObjectName="SupportAddress" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    64.         <table tableName="user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>  
    65.     
    66.     </context>  
    67. </generatorConfiguration>  

    4. 加上生成命令

        RunàEditConfigurationà+àMaven

        输入Command line

        mybatis-generator:generate

    5. Run

     

  • 相关阅读:
    leetcode 347. Top K Frequent Elements
    581. Shortest Unsorted Continuous Subarray
    leetcode 3. Longest Substring Without Repeating Characters
    leetcode 217. Contains Duplicate、219. Contains Duplicate II、220. Contains Duplicate、287. Find the Duplicate Number 、442. Find All Duplicates in an Array 、448. Find All Numbers Disappeared in an Array
    leetcode 461. Hamming Distance
    leetcode 19. Remove Nth Node From End of List
    leetcode 100. Same Tree、101. Symmetric Tree
    leetcode 171. Excel Sheet Column Number
    leetcode 242. Valid Anagram
    leetcode 326. Power of Three
  • 原文地址:https://www.cnblogs.com/figsprite/p/11100012.html
Copyright © 2011-2022 走看看