zoukankan      html  css  js  c++  java
  • 关于mybatisgenerator的问题

    1.运行完mybatis-generator没有出现问题,但是代码看不到,出现这种东西:

    你需要使用相对路径,如项目名+/src/main/java,就可以解决了

    2.附录我的代码以供参考:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
    <generatorConfiguration>
       
        <!-- 指定数据连接驱动jar地址 -->
        <classPathEntry location="D:/Java/maven-repository/repository/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar" />
    
        <!-- 一个数据库一个context -->
        <context id="infoGuardian" >
            <!-- 注释 -->
            <commentGenerator >
                <property name="suppressAllComments" value="false"/><!-- 是否取消注释 -->
                <property name="suppressDate" value="true" /> <!-- 是否生成注释代时间戳-->
            </commentGenerator>
    
            <!-- jdbc连接 -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                connectionURL="jdbc:mysql://127.0.0.1:3306/mall?characterEncoding=utf-8" userId="huhu"
                password="huhu" />
    
            <!-- 类型转换 -->
            <javaTypeResolver>
                <!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
                <property name="forceBigDecimals" value="false"/>
            </javaTypeResolver>
    
            <!-- 生成实体类地址 -->    
            <javaModelGenerator targetPackage="com.mall.pojo"
                targetProject="mall/src/main/java" >
                <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
                <property name="enableSubPackages" value="false"/>
                <!-- 是否针对string类型的字段在set的时候进行trim调用 -->
                <property name="trimStrings" value="true"/>
            </javaModelGenerator>
    
            <!-- 生成mapxml文件 -->
            <sqlMapGenerator targetPackage="mappers"
                targetProject="mall/src/main/resources" >
                <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
                <property name="enableSubPackages" value="false" />
            </sqlMapGenerator>
    
            <!-- 生成mapxml对应client,也就是接口dao -->  
            <javaClientGenerator targetPackage="com.mall.dao"
                targetProject="mall/src/main/resources" type="XMLMAPPER" >
                <!-- 是否在当前路径下新加一层schema,eg:fase路径com.oop.eksp.user.model, true:com.oop.eksp.user.model.[schemaName] -->
                <property name="enableSubPackages" value="false" />
            </javaClientGenerator>
    
            <!-- 配置表信息 表名,生成的类名,-->  
            <table schema="mall" tableName="mmall_cart"
                domainObjectName="Cart" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
                <!-- schema即为数据库名 tableName为对应的数据库表 domainObjectName是要生成的实体类 enable*ByExample 
                    是否生成 example类   -->
    
            </table>
            <table schema="mall" tableName="mmall_category"
                domainObjectName="Category" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
            </table>
            
            <table schema="mall" tableName="mmall_order"
                domainObjectName="Order" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
            </table>
            
            <table schema="mall" tableName="mmall_order_item"
                domainObjectName="OrderItem" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
            </table>
            
            <table schema="mall" tableName="mmall_pay_info"
                domainObjectName="PayInfo" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
            </table>
            
            <table schema="mall" tableName="mmall_product"
                domainObjectName="Product" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
                <!-- 指定列的java数据类型 -->
                <columnOverride column="sub_images" jdbcType="VARCHAR" />
                <columnOverride column="detail" jdbcType="VARCHAR" />
            </table>
    
            <table schema="mall" tableName="mmall_user"
                domainObjectName="User" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
            </table>
            
            <table schema="mall" tableName="mmall_shipping"
                domainObjectName="Shipping" enableCountByExample="false"
                enableDeleteByExample="false" enableSelectByExample="false"
                enableUpdateByExample="false">
            </table>
        </context>
    </generatorConfiguration>
  • 相关阅读:
    bootstrap实战练习中涉及的知识点(很有用哦!)
    Markdown的最常用标记符号有哪些?
    队列的插入 和出列 阻塞 时间 问题
    ArrayBlockingQueue和LinkedBlockingQueue的使用
    自己总结 :并发队列ConcurrentLinkedQueue、阻塞队列AraayBlockingQueue、阻塞队列LinkedBlockingQueue 区别 和 使用场景总结
    战斗由客户端来做,后端来验证 方式 解决 一些弊端思路
    类 文件 右下角呈现 红色小圆圈,里面有一个J 标记
    苏州儿童医保
    Error: opening registry key 'SoftwareJavaSoftJava Runtime Environment' could not find java.dll
    intellj(idea) 编译项目时在warnings 页签框里 报 “xxx包不存在” 或 “找不到符号” 或 “未结束的字符串字面值” 或 “需要)” 或 “需要;”等错误提示
  • 原文地址:https://www.cnblogs.com/huhu1203/p/7582413.html
Copyright © 2011-2022 走看看