IDEA mybatis-generator 逆向工程
生活随笔
收集整理的這篇文章主要介紹了
IDEA mybatis-generator 逆向工程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.在maven工程中的resource中創建generatorConfig.xml
2.配置generatorConfig.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfigurationPUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN""http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration><!-- 數據庫驅動:選擇你的本地硬盤上面的數據庫驅動包--><classPathEntry location="C:\Users\xx\.m2\repository\mysql\mysql-connector-java\5.1.35\mysql-connector-java-5.1.35.jar"/><context id="DB2Tables" targetRuntime="MyBatis3"><commentGenerator><property name="suppressDate" value="true"/><!-- 是否去除自動生成的注釋 true:是 : false:否 --><property name="suppressAllComments" value="true"/></commentGenerator><!--數據庫鏈接URL,用戶名、密碼 --><jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://xx:3306/xx" userId="xx" password="xx"></jdbcConnection><javaTypeResolver><property name="forceBigDecimals" value="false"/></javaTypeResolver><!-- 生成模型的包名和位置--><javaModelGenerator targetPackage="com.info.statistics.model" targetProject="src/main/java"><property name="enableSubPackages" value="true"/><property name="trimStrings" value="true"/></javaModelGenerator><!-- 生成映射文件的包名和位置--><sqlMapGenerator targetPackage="com.info.statistics.mapping" targetProject="src/main/java"><property name="enableSubPackages" value="true"/></sqlMapGenerator><!-- 生成DAO的包名和位置--><javaClientGenerator type="XMLMAPPER" targetPackage="com.info.statistics.dao" targetProject="src/main/java"><property name="enableSubPackages" value="true"/></javaClientGenerator><!-- 要生成的表 tableName是數據庫中的表名或視圖名 domainObjectName是實體類名--><table tableName="risk_model_order" domainObjectName="DSRiskModelOrder" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table><table tableName="tel_bill_record" domainObjectName="DSTelBillRecord" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table></context> </generatorConfiguration>3.配置pom.xml
<plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>1.3.2</version><configuration><configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile><overwrite>true</overwrite><verbose>true</verbose></configuration></plugin>4.生成對象的兩種方式
方式一:使用idea的maven插件直接快速生成
雙擊mybatis-generator:generate就可生成
方式二:在IDEA添加一個“Run運行”選項,使用maven運行mybatis-generator-maven-plugin插件
mybatis-generator:generate -e 加-e是為了輸出詳細信息
?
轉載于:https://www.cnblogs.com/fswhq/p/mybatis-generator.html
總結
以上是生活随笔為你收集整理的IDEA mybatis-generator 逆向工程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: List、Set、Map的区别
- 下一篇: AtCoder Regular Cont