av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

MyBatis Generator的簡(jiǎn)單使用方法示例

瀏覽:44日期:2023-10-19 18:55:04
添加配置文件

在項(xiàng)目resource目錄下創(chuàng)建mybatis-generator文件夾

MyBatis Generator的簡(jiǎn)單使用方法示例

在文件夾下創(chuàng)建generatorConfig.xml,配置需要生成代碼的數(shù)據(jù)表

<?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> <properties resource='mybatis-generator/generator.properties'/> <!-- 連接數(shù)據(jù)庫(kù)jar包的路徑--> <!--<classPathEntry location='d:/java/JavaTools/mysql-connector-java-5.1.48/mysql-connector-java-5.1.48-bin.jar'/>--> <context targetRuntime='MyBatis3'> <commentGenerator> <property name='suppressDate' value='true'/> <!-- 是否去除自動(dòng)生成的注釋 true:是 : false:否 --> <property name='suppressAllComments' value='true'/> </commentGenerator> <!--數(shù)據(jù)庫(kù)連接參數(shù) --> <jdbcConnection driverClass='${driverClassName}' connectionURL='${url}' userId='${username}' password='${password}'> </jdbcConnection> <javaTypeResolver> <property name='forceBigDecimals' value='false'/> </javaTypeResolver> <!-- 實(shí)體類(lèi)的包名和存放路徑 --> <javaModelGenerator targetPackage='com.shop.order.bean' targetProject='src/main/java'> <property name='enableSubPackages' value='true'/> <property name='trimStrings' value='true'/> </javaModelGenerator> <!-- 生成映射文件*.xml的位置--> <sqlMapGenerator targetPackage='mapper' targetProject='src/main/resources'> <property name='enableSubPackages' value='true'/> </sqlMapGenerator> <!-- 生成DAO的包名和位置 --> <javaClientGenerator type='XMLMAPPER' targetPackage='com.shop.order.mapper' targetProject='src/main/java'> <property name='enableSubPackages' value='true'/> </javaClientGenerator> <!-- tableName:數(shù)據(jù)庫(kù)中的表名或視圖名;domainObjectName:生成的實(shí)體類(lèi)的類(lèi)名--> <table tableName='book' domainObjectName='Book' enableCountByExample='false' enableUpdateByExample='false' enableDeleteByExample='false' enableSelectByExample='false' selectByExampleQueryId='false'/> <!-- 可以添加多個(gè)需要生產(chǎn)代碼的實(shí)體--> <!-- <table tableName='xxx' domainObjectName='xxx' enableCountByExample='false' enableUpdateByExample='false' enableDeleteByExample='false' enableSelectByExample='false' selectByExampleQueryId='false'/> ... <table tableName='xxx' domainObjectName='xxx' enableCountByExample='false' enableUpdateByExample='false' enableDeleteByExample='false' enableSelectByExample='false' selectByExampleQueryId='false'/> --> </context></generatorConfiguration>

在文件夾下創(chuàng)建generator.properties配置文件

driverClassName=com.mysql.jdbc.Driverurl=jdbc:mysql://localhost:3306/store?useUnicode=true&characterEncoding=UTF-8&relaxAutoCommit=true&zeroDateTimeBehavior=convertToNullusername=rootpassword=root配置Maven

pom.xml中引入依賴(lài)

<build> <plugins> <plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>1.3.5</version><configuration> <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile> <verbose>true</verbose> <overwrite>true</overwrite></configuration><executions> <execution> <id>Generate MyBatis Artifacts</id> <goals> <goal>generate</goal> </goals> </execution></executions><dependencies> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.5</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.30</version> </dependency></dependencies> </plugin> </plugins> </build>執(zhí)行Maven插件

雙擊運(yùn)行mybatis-generator:generate

MyBatis Generator的簡(jiǎn)單使用方法示例

控制臺(tái)輸出結(jié)果,生產(chǎn)mapper和bean文件

MyBatis Generator的簡(jiǎn)單使用方法示例

總結(jié)

到此這篇關(guān)于MyBatis Generator簡(jiǎn)單使用方法的文章就介紹到這了,更多相關(guān)MyBatis Generator使用內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

相關(guān)文章:
主站蜘蛛池模板: 国产精品久久久久aaaa九色 | 亚洲欧美一区二区三区国产精品 | 午夜欧美一区二区三区在线播放 | 伊人导航| 伊人看片| 欧美精品一区二区三区一线天视频 | 国产日韩一区二区 | 欧美最猛性xxxxx亚洲精品 | 一区二区在线观看免费视频 | 精品亚洲一区二区 | 国产在线精品区 | 亚洲欧美日韩系列 | 免费精品在线视频 | 欧美成人精品一区二区三区 | 成人午夜视频在线观看 | 91电影在线 | 欧美xxxx网站 | 午夜手机在线视频 | 激情综合五月 | 色婷婷一区 | 亚洲精品一 | 91免费看片| 欧美一区在线视频 | 日本一区二区影视 | 国产成人精品网站 | 国产视频久久 | 影音先锋成人资源 | 欧美一区视频 | 一区欧美 | 亚洲在线看 | 伊人精品久久久久77777 | 欧美日本一区 | 亚洲一区二区三区在线视频 | 九九国产 | 欧美日韩在线成人 | 99精品免费视频 | 国产91久久久久久 | 久久国产亚洲 | 亚洲嫩草 | 欧美成人黄色小说 | 成人久久18免费网站 |