亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

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

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

瀏覽:6日期: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
相關文章:
主站蜘蛛池模板: 欧美日韩国产一区二区三区 | 亚洲最新| 韩国无遮挡三级伦在线大全 | 五月开心六月伊人色婷婷 | 关婷哪一级毛片高清免费看 | 中文字幕第一页在线播放 | 国产成人19禁在线观看 | 婷婷色香五月激情综合2020 | 国产一区二区三区波多野吉衣 | 国产精品播放 | 视频精品一区二区三区 | 亚洲成人中文 | 在线观看222www| 黄色片免费看视频 | 可以免费看黄的网站 | 免费永久国产在线视频 | 国产特黄特色的大片观看免费视频 | 国产首页精品 | 欧美色视频日本片免费高清 | 免费看黄网址 | 欧美性一区| 国产精品亚洲综合网站 | 你操综合 | 嫩草视频在线观看www视频 | 麻豆爱爱视频 | 亚洲欧美一区二区视频 | 国偷盗摄自产福利一区在线 | 久久久久国产一级毛片高清版 | 国产区网址 | 91视频免费播放 | 一道精品一区二区三区 | 成人网视频在线观看免费 | 手机看片欧美日韩 | 一级做性色a爰片久久毛片 一级做性色a爰片久久毛片免费 | 久久久久久久久久综合情日本 | 91尤物国产尤物福利 | 日韩在线视屏 | 久久精品福利视频 | 成人国产精品高清在线观看 | 毛片网站在线观看 | 欧美一级专区免费大片俄罗斯 |