电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術文章
文章詳情頁

SpringBoot使用Mybatis-Generator配置過程詳解

瀏覽:4日期:2023-05-30 09:41:33

:> 使用Spring initialier 需要配置文件

SpringBoot使用Mybatis-Generator配置過程詳解

POM文件

復制代碼 代碼如下:<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <executions> <execution> <id>mybatis-generator</id> <phase>deploy</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <!-- Mybatis-Generator 工具配置文件的位置 --> <configurationFile>src/main/resources/mybatis-generator/generatorConfig.xml</configurationFile> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.19</version> </dependency> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.2</version>a </dependency> </dependencies> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>exec</classifier> </configuration> </plugin> </plugins> </build>1: application配置文件

復制代碼 代碼如下:## mapper xml 文件地址mybatis.mapper-locations=classpath*:mapper/*Mapper.xml##數據庫urlspring.datasource.url=jdbc:mysql://localhost/test2?userSSL=true&useUnicode=true&characterEncoding=UTF8&serverTimezone=GMT##數據庫用戶名spring.datasource.username=root##數據庫密碼spring.datasource.password=root##數據庫驅動spring.datasource.driver-class-name=com.mysql.jdbc.Driver#Mybatis Generator configuration#dao類和實體類的位置mybatis.project =src/main/java#mapper文件的位置mybatis.resources=src/main/resources配置 Mybatis-Generator復制代碼 代碼如下:<?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> <!--執行generator插件生成文件的命令: call mvn mybatis-generator:generate -e --> <!-- 引入配置文件 --> <properties resource='application.properties'/> <!--classPathEntry:數據庫的JDBC驅動,換成你自己的驅動位置 可選 --> <!--<classPathEntry location='D:generator_mybatismysql-connector-java-5.1.24-bin.jar' /> --> <!-- 一個數據庫一個context --> <!--defaultModelType='flat' 大數據字段,不分表 --> <context targetRuntime='MyBatis3Simple' defaultModelType='flat'> <!-- 自動識別數據庫關鍵字,默認false,如果設置為true,根據SqlReservedWords中定義的關鍵字列表; 一般保留默認值,遇到數據庫關鍵字(Java關鍵字),使用columnOverride覆蓋 --> <property name='autoDelimitKeywords' value='true' /> <!-- 生成的Java文件的編碼 --> <property name='javaFileEncoding' value='utf-8' /> <!-- beginningDelimiter和endingDelimiter:指明數據庫的用于標記數據庫對象名的符號,比如ORACLE就是雙引號,MYSQL默認是`反引號; --> <property name='beginningDelimiter' value='`' /> <property name='endingDelimiter' value='`' /> <!-- 格式化java代碼 --> <property name='javaFormatter' value='org.mybatis.generator.api.dom.DefaultJavaFormatter'/> <!-- 格式化XML代碼 --> <property name='xmlFormatter' value='org.mybatis.generator.api.dom.DefaultXmlFormatter'/> <plugin type='org.mybatis.generator.plugins.SerializablePlugin' /> <plugin type='org.mybatis.generator.plugins.ToStringPlugin' /> <!-- 注釋 --> <commentGenerator > <property name='suppressAllComments' value='false'/><!-- 是否取消注釋 --> <property name='suppressDate' value='true' /> <!-- 是否生成注釋代時間戳--> </commentGenerator> <!-- jdbc連接 --> <jdbcConnection driverClass='${spring.datasource.driver-class-name}' connectionURL='${spring.datasource.url}' userId='${spring.datasource.username}' password='${spring.datasource.password}' /> <!-- 類型轉換 --> <javaTypeResolver> <!-- 是否使用bigDecimal, false可自動轉化以下類型(Long, Integer, Short, etc.) --> <property name='forceBigDecimals' value='false'/> </javaTypeResolver> <!-- 生成實體類地址 --> <javaModelGenerator targetPackage='com.dgw.mybatisgenerator.entity' targetProject='${mybatis.project}' > <property name='enableSubPackages' value='false'/> <property name='trimStrings' value='true'/> </javaModelGenerator> <!-- 生成mapxml文件 --> <sqlMapGenerator targetPackage='mapper' targetProject='${mybatis.resources}' > <property name='enableSubPackages' value='false' /> </sqlMapGenerator> <!-- 生成mapxml對應client,也就是接口dao --> <javaClientGenerator targetPackage='com.dgw.mybatisgenerator.dao' targetProject='${mybatis.project}' type='XMLMAPPER' > <property name='enableSubPackages' value='false' /> </javaClientGenerator> <!-- table可以有多個,每個數據庫中的表都可以寫一個table,tableName表示要匹配的數據庫表,也可以在tableName屬性中通過使用%通配符來匹配所有數據庫表,只有匹配的表才會自動生成文件 --> <table tableName='user' enableCountByExample='true' enableUpdateByExample='true' enableDeleteByExample='true' enableSelectByExample='true' selectByExampleQueryId='true'> <property name='useActualColumnNames' value='false' /> <!-- 數據庫表主鍵 --> <generatedKey column='id' sqlStatement='Mysql' identity='true' /> </table> <!-- <table tableName='book' enableCountByExample='true' enableUpdateByExample='true' enableDeleteByExample='true' enableSelectByExample='true' selectByExampleQueryId='true'> <property name='useActualColumnNames' value='false' /> &lt;!&ndash; 數據庫表主鍵 &ndash;&gt; <generatedKey column='id' sqlStatement='Mysql' identity='true' /> </table>--> </context></generatorConfiguration>3: 進行配置

右側Maven處點擊如圖所示位置

SpringBoot使用Mybatis-Generator配置過程詳解

測試陳宮

SpringBoot使用Mybatis-Generator配置過程詳解

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
主站蜘蛛池模板: 丽陂特官网_手机信号屏蔽器_Wifi信号干扰器厂家_学校考场工厂会议室屏蔽仪 | 莱州网络公司|莱州网站建设|莱州网站优化|莱州阿里巴巴-莱州唯佳网络科技有限公司 | 进口消泡剂-道康宁消泡剂-陶氏消泡剂-大洋消泡剂 | 上海盐水喷雾试验机_两厢式冷热冲击试验箱-巨怡环试 | 西装定制/做厂家/公司_西装订做/制价格/费用-北京圣达信西装 | 模切之家-专注服务模切行业的B2B平台! | 胶辊硫化罐_胶鞋硫化罐_硫化罐厂家-山东鑫泰鑫智能装备有限公司 意大利Frascold/富士豪压缩机_富士豪半封闭压缩机_富士豪活塞压缩机_富士豪螺杆压缩机 | 手术室净化厂家-成都做医院净化工程的公司-四川华锐-15年特殊科室建设经验 | 中视电广_短视频拍摄_短视频推广_短视频代运营_宣传片拍摄_影视广告制作_中视电广 | 实战IT培训机构_IT培训班选大学生IT技术培训中心_中公优就业 | 检验科改造施工_DSA手术室净化_导管室装修_成都特殊科室建设厂家_医疗净化工程公司_四川华锐 | 考勤系统_人事考勤管理系统_本地部署BS考勤系统_考勤软件_天时考勤管理专家 | 跨境物流_美国卡派_中大件运输_尾程派送_海外仓一件代发 - 广州环至美供应链平台 | 泥浆在线密度计厂家-防爆数字压力表-膜盒-远传压力表厂家-江苏大亚自控设备有限公司 | 郑州宣传片拍摄-TVC广告片拍摄-微电影短视频制作-河南优柿文化传媒有限公司 | 叉车电池-叉车电瓶-叉车蓄电池-铅酸蓄电池-电动叉车蓄电池生产厂家 | 东莞市超赞电子科技有限公司 全系列直插/贴片铝电解电容,电解电容,电容器 | 避光流动池-带盖荧光比色皿-生化流动比色皿-宜兴市晶科光学仪器 东莞爱加真空科技有限公司-进口真空镀膜机|真空镀膜设备|Polycold维修厂家 | 塑胶跑道_学校塑胶跑道_塑胶球场_运动场材料厂家_中国塑胶跑道十大生产厂家_混合型塑胶跑道_透气型塑胶跑道-广东绿晨体育设施有限公司 | 济南货架定做_仓储货架生产厂_重型货架厂_仓库货架批发_济南启力仓储设备有限公司 | 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 二维运动混料机,加热型混料机,干粉混料机-南京腾阳干燥设备厂 | 安徽集装箱厂-合肥国彩钢结构板房工程有限公司 | 变色龙云 - 打包app_原生app_在线制作平台_短链接_ip查询 | 金属波纹补偿器厂家_不锈钢膨胀节价格_非金属伸缩节定制-庆达补偿器 | 【德信自动化】点胶机_全自动点胶机_自动点胶机厂家_塑料热压机_自动螺丝机-深圳市德信自动化设备有限公司 | 钢格板|镀锌钢格板|热镀锌钢格板|格栅板|钢格板|钢格栅板|热浸锌钢格板|平台钢格板|镀锌钢格栅板|热镀锌钢格栅板|平台钢格栅板|不锈钢钢格栅板 - 专业钢格板厂家 | 开业庆典_舞龙舞狮_乔迁奠基仪式_开工仪式-神挚龙狮鼓乐文化传媒 | 防爆电机_防爆电机型号_河南省南洋防爆电机有限公司 | 南京PVC快速门厂家南京快速卷帘门_南京pvc快速门_世界500强企业国内供应商_南京美高门业 | 数显恒温培养摇床-卧式/台式恒温培养摇床|朗越仪器 | 实战IT培训机构_IT培训班选大学生IT技术培训中心_中公优就业 | 棉柔巾代加工_洗脸巾oem_一次性毛巾_浴巾生产厂家-杭州禾壹卫品科技有限公司 | 振动传感器,检波器-威海广达勘探仪器有限公司 | 数控车床-立式加工中心-多功能机床-小型车床-山东临沂金星机床有限公司 | 导电银胶_LED封装导电银胶_半导体封装导电胶厂家-上海腾烁 | 发电机组|柴油发电机组-批发,上柴,玉柴,潍柴,康明斯柴油发电机厂家直销 | 电动葫芦|手拉葫芦|环链电动葫芦|微型电动葫芦-北京市凌鹰起重机械有限公司 | 电梯乘运质量测试仪_电梯安全评估测试仪-武汉懿之刻 | 雨燕360体育免费直播_雨燕360免费NBA直播_NBA篮球高清直播无插件-雨燕360体育直播 | 钢绞线万能材料试验机-全自动恒应力两用机-混凝土恒应力压力试验机-北京科达京威科技发展有限公司 |