zoukankan      html  css  js  c++  java
  • Maven项目自动生成mybaties配置文件

    1、把mysql-connector-java-5.1.31.jar包放到C盘的mysqljar文件夹下

    2、在generatorConfig.xml文件中配置实体、dao、service等包

    <?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>
        <classPathEntry
            location="C:/mysqljar/mysql-connector-java-5.1.31.jar"/>
        <context id="context1">
             
        
            <!-- 生成文件编码 -->
            <property name="javaFileEncoding" value="UTF-8"/>
        
            <!-- 是否去除自动生成的注释 true:是 : false:否 -->  
            <commentGenerator>  
                <property name="suppressDate" value="true"/>  
                <property name="suppressAllComments" value="true"/>  
            </commentGenerator>  
        
        
           <!-- 数据库  -->
            <jdbcConnection driverClass="com.mysql.jdbc.Driver"
                connectionURL="jdbc:mysql://127.0.0.1:3306/future?useUnicode=true&amp;characterEncoding=UTF-8"
                userId="root" password="root" />
            
                  <!-- 生成模型的包名和位置-->  
            <javaModelGenerator targetPackage="com.future.base.dao.entity" targetProject="future-base"> 
                <property name="enableSubPackages" value="true"/>  
                <property name="trimStrings" value="true"/>  
            </javaModelGenerator>    
                
             <!-- 生成映射文件的包名和位置-->  
           <sqlMapGenerator targetPackage="com.future.base.dao.mapper" targetProject="future-base">  
                <property name="enableSubPackages" value="true"/>  
            </sqlMapGenerator> 
            
            <!-- 生成DAO的包名和位置-->                                                       
           <javaClientGenerator type="XMLMAPPER" targetPackage="com.future.base.dao" targetProject="future-base">  
                <property name="enableSubPackages" value="true"/>  
            </javaClientGenerator>
            
    
     
    <!--                           表名                              实体   -->
               <table tableName="reader_type"  domainObjectName="ReaderType" >
    <!--               有主键 id   就加 。。没有  就 不要这个 -->
               <generatedKey column="id" sqlStatement="MySql" identity="true"/>
               </table>    
             </context>
    </generatorConfiguration>

    3、generatorConfig.xml右键Generate Mybities/iBATIES  Artifacts 即可 就可以在对应的包下生成文件

  • 相关阅读:
    openwrt官方固件怎么中继网络
    hibernate 映射一对多
    jsp连接access数据库
    表单判断值是否为空
    eclipse java ee jsp tomcat Server文件夹给删了,怎么办?
    Provided id of the wrong type for class pojo.Books. Expected: class java.lang.Integer, got class java.lang.Long
    myeclipse创建hibernate工程
    Caused by: java.sql.SQLException: Field 'id' doesn't have a default value
    Mac 挂载树莓派nfs
    树莓派集群实践——nfs
  • 原文地址:https://www.cnblogs.com/xinxin1994/p/6080504.html
Copyright © 2011-2022 走看看