• generator idea自动生成pojo ------- 配置文件


    1....generator 安装包

    https://pan.baidu.com/s/1jDkJxijMdHkn6m3YasKiuw         提取码:cifj

    2...下载并解压到本地,idea打开为一级目录(注:不要创建工程,一级目录为:generator)

    3...修改   generatorConfig.xml  配置文件:

    <!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
    <jdbcConnection driverClass="com.mysql.jdbc.Driver"
       connectionURL="jdbc:mysql://localhost:3306/pinyougou" userId="root"
       password="wsc">
    </jdbcConnection>

    需要的配置文件:代码中的 红颜色  :

    pinyougou:数据库名称 ,
    userId:数据库登录名 ,
    password :数据库登录密码;

    4.... 创建pojo ,dao,resoureces下的mapper映射文件(SQL语句)

     1 <!-- targetProject:生成pojo类的位置 -->
     2 <javaModelGenerator targetPackage="com.wsc.core.pojo"
     3    targetProject=".src">
     4    <!-- enableSubPackages:是否让schema作为包的后缀 -->
     5    <property name="enableSubPackages" value="false" />
     6    <!-- 从数据库返回的值被清理前后的空格 -->
     7    <property name="trimStrings" value="true" />
     8 </javaModelGenerator>
     9 
    10       <!-- targetProject:mapper映射文件生成的位置 -->
    11 <sqlMapGenerator targetPackage="com.wsc.core.dao"
    12    targetProject=".
    esources">
    13    <!-- enableSubPackages:是否让schema作为包的后缀 -->
    14    <property name="enableSubPackages" value="false" />
    15 </sqlMapGenerator>
    16 <!-- targetPackage:mapper接口生成的位置 -->
    17 <javaClientGenerator type="XMLMAPPER"
    18    targetPackage="com.wsc.core.dao"
    19    targetProject=".src">
    20    <!-- enableSubPackages:是否让schema作为包的后缀 -->
    21    <property name="enableSubPackages" value="true" />
    22 </javaClientGenerator>
    5....数据库对应的字段名:
    tableName 表名   
    domainObjectName:重命名
        <!-- 指定数据库表 -->
            <table schema="" tableName="tb_order" domainObjectName="order.Order"/>
            <table schema="" tableName="tb_order_item" domainObjectName="order.OrderItem"/>
            <table schema="" tableName="tb_address" domainObjectName="address.Address"/>
            <table schema="" tableName="tb_areas" domainObjectName="address.Areas"/>
            <table schema="" tableName="tb_cities" domainObjectName="address.Cities"/>
            <table schema="" tableName="tb_provinces" domainObjectName="address.Provinces"/>
            <table schema="" tableName="tb_content" domainObjectName="ad.Content"/>
            <table schema="" tableName="tb_content_category" domainObjectName="ad.ContentCategory"/>
            <table schema="" tableName="tb_pay_log" domainObjectName="log.PayLog"/>
            <table schema="" tableName="tb_seller" domainObjectName="seller.Seller"/>
            <table schema="" tableName="tb_user" domainObjectName="user.User"/>
            <table schema="" tableName="tb_brand" domainObjectName="good.Brand"/>
            <table schema="" tableName="tb_goods" domainObjectName="good.Goods"/>
            <table schema="" tableName="tb_goods_desc" domainObjectName="good.GoodsDesc"/>
            <table schema="" tableName="tb_specification" domainObjectName="specification.Specification"/>
            <table schema="" tableName="tb_specification_option" domainObjectName="specification.SpecificationOption"/>
            <table schema="" tableName="tb_type_template" domainObjectName="template.TypeTemplate"/>
            <table schema="" tableName="tb_freight_template" domainObjectName="template.FreightTemplate"/>
            <table schema="" tableName="tb_item_cat" domainObjectName="item.ItemCat"/>
            <table schema="" tableName="tb_item" domainObjectName="item.Item"/>
            <table schema="" tableName="tb_seckill_goods" domainObjectName="seckill.SeckillGoods"/>
            <table schema="" tableName="tb_seckill_order" domainObjectName="seckill.SeckillOrder"/>

    6...运行 src/org/GeneratorSqlmap 里的java文件

    1 public static void main(String[] args) throws Exception {
    2         try {
    3             GeneratorSqlmap generatorSqlmap = new GeneratorSqlmap();
    4             generatorSqlmap.generator();
    5         } catch (Exception e) {
    6             e.printStackTrace();
    7         }
    8         
    9     }

     

     

     

  • 相关阅读:
    Android url中文编码问题
    android studio error configuration with name default not found
    Android studio 配置JNI环境
    Github获取仓库最新Release版本号API
    微信小程序开发——设置默认图片、错误加载图片
    微信小程序开发-rem转换rpx小工具
    微信小程序开发小技巧——单击事件传参、动态修改样式、轮播样式修改等
    解决vue-router嵌套路由(子路由)在history模式下刷新无法渲染页面的问题
    VUE图片懒加载-vue lazyload插件的简单使用
    vue项目微信分享之后路由链接被破坏怎么办
  • 原文地址:https://www.cnblogs.com/wangshichang/p/11354070.html
Copyright © 2020-2023  润新知