程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA綜合教程 >> mybatis generator with oracle,mybatisgenerator

mybatis generator with oracle,mybatisgenerator

編輯:JAVA綜合教程

mybatis generator with oracle,mybatisgenerator


1.generator.xml

<?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:\Users\rocky\.m2\repository\com\oracle\ojdbc6\11.2.0.1.0\ojdbc6-11.2.0.1.0.jar" />

    <context id="MyBatis3" targetRuntime="MyBatis3">
        
        <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@192.168.1.5:1521:MYDB"
            userId="rocky" password="rocky">
        </jdbcConnection>
        
        <javaModelGenerator targetPackage="com.myproject.rocky.web.model" targetProject="./src">
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="com.myproject.rocky.web.dao" targetProject="./src">
        </sqlMapGenerator>

        <javaClientGenerator type="XMLMAPPER" targetPackage="com.myproject.rocky.web.dao"
            targetProject="./src">
        </javaClientGenerator>
    
        <table tableName="OBJ_USER" schema="rocky" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
    enableSelectByExample="false" selectByExampleQueryId="false">
            <property name="ignoreQualifiersAtRuntime" value="true" />
            <property name="runtimeTableName" value="OBJ_USER" />
            
        </table>
    </context>
</generatorConfiguration>

2.  mybatis-generator-core-1.3.2.jar

3.  java -jar mybatis-generator-core-1.3.2.jar -configfile generator.xml -overwrite

4. some problems:

   ~if the table short of primary key, you maynot generate the right mapper file and interface(only has the insert method).

 

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved