IDEA mybatis-generator逆向工程生成代碼
1.在maven工程中的resource中創(chuàng)建generatorConfig.xml
2.配置generatorConfig.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> <!-- 數(shù)據(jù)庫(kù)驅(qū)動(dòng):選擇你的本地硬盤上面的數(shù)據(jù)庫(kù)驅(qū)動(dòng)包--> <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"/> <!-- 是否去除自動(dòng)生成的注釋 true:是 : false:否 --> <property name="suppressAllComments" value="true"/> </commentGenerator> <!--數(shù)據(jù)庫(kù)鏈接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是數(shù)據(jù)庫(kù)中的表名或視圖名 domainObjectName是實(shí)體類名--> <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>/src/main/resources/generator/generatorConfig.xml</configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> </plugin>
4.生成對(duì)象的兩種方式
方式一:使用idea的maven插件直接快速生成
雙擊mybatis-generator:generate就可生成
方式二:在IDEA添加一個(gè)“Run運(yùn)行”選項(xiàng),使用maven運(yùn)行mybatis-generator-maven-plugin插件
mybatis-generator:generate -e 加-e是為了輸出詳細(xì)信息
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
IDEA2022版本創(chuàng)建maven?web項(xiàng)目的兩種方式詳解
創(chuàng)建maven?web項(xiàng)目有兩種方式,一種是使用骨架方式,一種是不使用骨架的方式,本文結(jié)合實(shí)例代碼給大家介紹了IDEA2022版本創(chuàng)建maven?web項(xiàng)目的兩種方式,需要的朋友可以參考下2023-02-02ShardingSphere結(jié)合MySQL實(shí)現(xiàn)分庫(kù)分表的項(xiàng)目實(shí)踐
在實(shí)際開(kāi)發(fā)中,如果表的數(shù)據(jù)過(guò)大我們需要把一張表拆分成多張表,本文主要介紹了使用ShardingSphere實(shí)現(xiàn)MySQL分庫(kù)分表,具有一定的參考價(jià)值,感興趣的可以了解一下2024-03-03java實(shí)時(shí)監(jiān)控文件行尾內(nèi)容的實(shí)現(xiàn)
這篇文章主要介紹了java實(shí)時(shí)監(jiān)控文件行尾內(nèi)容的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-02-02MultipartFile中transferTo(File file)的路徑問(wèn)題及解決
這篇文章主要介紹了MultipartFile中transferTo(File file)的路徑問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07圖文精講java常見(jiàn)分布式事務(wù)理論與解決方案
對(duì)于分布式系統(tǒng),最簡(jiǎn)單的理解就是一堆機(jī)器對(duì)外提供服務(wù),相比單體服務(wù),它可以承受更高的負(fù)載,但是分布式系統(tǒng)也帶了一系列問(wèn)題,今天帶大家搞懂和分布式相關(guān)的常見(jiàn)理論和解決方案2021-11-11