最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時(shí)間:2020年02月26日 13:35:47   投稿:yaominghui  
這篇文章主要介紹了SpringBoot使用Mybatis-Generator配置過程詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

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

POM文件


復(fù)制代碼 代碼如下:
<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配置文件

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

右側(cè)Maven處點(diǎn)擊如圖所示位置


測(cè)試陳宮

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java8中stream流的collectingAndThen方法應(yīng)用實(shí)例詳解

    Java8中stream流的collectingAndThen方法應(yīng)用實(shí)例詳解

    Java8中的Stream流提供了collectingAndThen方法,用于對(duì)歸納結(jié)果進(jìn)行二次處理,文章通過User類的數(shù)據(jù)填充,演示了如何使用該方法進(jìn)行集合去重、查找最高工資員工、計(jì)算平均工資等操作,感興趣的朋友跟隨小編一起看看吧
    2025-03-03
  • Java如何分析算法的時(shí)間和空間復(fù)雜度

    Java如何分析算法的時(shí)間和空間復(fù)雜度

    這篇文章主要介紹了Java如何分析算法的時(shí)間和空間復(fù)雜度,在計(jì)算機(jī)科學(xué)中,計(jì)算復(fù)雜性解釋了算法的性能。文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-06-06
  • Spring @Valid和@Validated區(qū)別和用法實(shí)例

    Spring @Valid和@Validated區(qū)別和用法實(shí)例

    這篇文章主要介紹了Spring @Valid和@Validated區(qū)別和用法實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04
  • 詳細(xì)了解MVC+proxy

    詳細(xì)了解MVC+proxy

    Java有兩種代理方式,一種是靜態(tài)代理,另一種是動(dòng)態(tài)代理。對(duì)于靜態(tài)代理,其實(shí)就是通過依賴注入,對(duì)對(duì)象進(jìn)行封裝,不讓外部知道實(shí)現(xiàn)的細(xì)節(jié)。很多 API 就是通過這種形式來封裝的
    2021-07-07
  • 為何HashSet中使用PRESENT而不是null作為value

    為何HashSet中使用PRESENT而不是null作為value

    這篇文章主要介紹了為何HashSet中使用PRESENT而不是null作為value,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • jenkins如何部署應(yīng)用到多個(gè)環(huán)境

    jenkins如何部署應(yīng)用到多個(gè)環(huán)境

    本文介紹了如何基于流水線的方式將應(yīng)用程序部署到多個(gè)環(huán)境,包括測(cè)試環(huán)境和生產(chǎn)環(huán)境,通過創(chuàng)建項(xiàng)目、設(shè)置參數(shù)、配置流水線、設(shè)置環(huán)境變量、配置Maven工具、構(gòu)建階段、部署測(cè)試環(huán)境和生產(chǎn)環(huán)境、以及清理階段,實(shí)現(xiàn)了自動(dòng)化部署流程
    2024-11-11
  • Java連接MQ實(shí)現(xiàn)信息查詢的操作過程

    Java連接MQ實(shí)現(xiàn)信息查詢的操作過程

    本文介紹了如何使用Java連接ApacheRocketMQ實(shí)現(xiàn)信息查詢的功能,通過編寫Java代碼連接MQ并實(shí)現(xiàn)生產(chǎn)者發(fā)送消息和消費(fèi)者接收并處理消息的過程,展示了如何在分布式系統(tǒng)中實(shí)現(xiàn)訂單處理系統(tǒng)的解耦,感興趣的朋友跟隨小編一起看看吧
    2024-11-11
  • JDK10新特性之var泛型和多個(gè)接口實(shí)現(xiàn)方法

    JDK10新特性之var泛型和多個(gè)接口實(shí)現(xiàn)方法

    這篇文章主要介紹了JDK10的新特性:var泛型和多個(gè)接口實(shí)現(xiàn)方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-05-05
  • Spring項(xiàng)目接入DeepSeek的兩種超簡單的方式分享

    Spring項(xiàng)目接入DeepSeek的兩種超簡單的方式分享

    DeepSeek?作為一款卓越的國產(chǎn)?AI?模型,越來越多的公司考慮在自己的應(yīng)用中集成,本文為大家?分享了Spring項(xiàng)目接入DeepSeek的兩種超簡單的方式,希望對(duì)大家有所幫助
    2025-02-02
  • IDEA 離線遷移Springboot工程的方法步驟

    IDEA 離線遷移Springboot工程的方法步驟

    這篇文章主要介紹了IDEA 離線遷移Springboot工程的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06

最新評(píng)論

纳雍县| 景泰县| 南京市| 凭祥市| 都兰县| 吴堡县| 南江县| 绍兴市| 长宁县| 正定县| 高州市| 竹溪县| 饶平县| 毕节市| 和政县| 谢通门县| 宜兰市| 灵宝市| 莒南县| 永寿县| 博客| 贵溪市| 东乡| 保定市| 陇西县| 颍上县| 丰镇市| 鞍山市| 贵定县| 驻马店市| 清流县| 睢宁县| 彭州市| 秦皇岛市| 盐山县| 峨眉山市| 湘潭市| 长顺县| 麦盖提县| 皮山县| 临猗县|