Help--Eclipser Marketplace中查找:Mybatis Generator 1.3.5安裝java
New--other--查找以下sql
點擊next,選擇你要將文件生成到哪裏的項目名數據庫
點擊finish關閉。就會在hhh項目中生成文件generatorConfig.xml。mybatis
注意:hhh項目中要有數據庫相關jar包及要生成的包 mapper/pojo,由於一會要在配置文件中進行配置。oracle
<?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> <context id="testTables" targetRuntime="MyBatis3"> <commentGenerator> <!-- 是否去除自動生成的註釋 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <!--數據庫鏈接的信息:驅動類、鏈接地址、用戶名、密碼 --> <!-- <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@150.16.17.22:1521/wsbs" userId="hr" password="hr123"> </jdbcConnection>--> <jdbcConnection driverClass="oracle.jdbc.OracleDriver" connectionURL="jdbc:oracle:thin:@150.16.17.22:1521:wsbs" userId="hr" password="hr123"> </jdbcConnection> <!-- 默認false,把JDBC DECIMAL 和 NUMERIC 類型解析爲 Integer,爲 true時把JDBC DECIMAL 和 NUMERIC 類型解析爲java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- targetProject:生成PO類的位置 --> <javaModelGenerator targetPackage="cn.herry.pojo" targetProject="hhh/src"> <!-- enableSubPackages:是否讓schema做爲包的後綴 --> <property name="enableSubPackages" value="false" /> <!-- 從數據庫返回的值被清理先後的空格 --> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- targetProject:mapper映射文件生成的位置 --> <sqlMapGenerator targetPackage="cn.herry.mapper" targetProject="hhh/src"> <!-- enableSubPackages:是否讓schema做爲包的後綴 --> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!-- targetPackage:mapper接口生成的位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="cn.herry.mapper" targetProject="hhh/src"> <!-- enableSubPackages:是否讓schema做爲包的後綴 --> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!-- 指定數據庫表 --> <!--<table tableName="items"></table> --> <table tableName="demo"></table> </context> </generatorConfiguration>
右鍵generatorConfig.xml,選擇以下:app
以後,就能夠在包下看到生成的文件了eclipse
End!spa