亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

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

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##數(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ū)動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> <!--執(zhí)行generator插件生成文件的命令: call mvn mybatis-generator:generate -e --> <!-- 引入配置文件 --> <properties resource="application.properties"/> <!--classPathEntry:數(shù)據(jù)庫的JDBC驅(qū)動,換成你自己的驅(qū)動位置 可選 --> <!--<classPathEntry location="D:\generator_mybatis\mysql-connector-java-5.1.24-bin.jar" /> --> <!-- 一個數(shù)據(jù)庫一個context --> <!--defaultModelType="flat" 大數(shù)據(jù)字段,不分表 --> <context targetRuntime="MyBatis3Simple" defaultModelType="flat"> <!-- 自動識別數(shù)據(jù)庫關鍵字,默認false,如果設置為true,根據(jù)SqlReservedWords中定義的關鍵字列表; 一般保留默認值,遇到數(shù)據(jù)庫關鍵字(Java關鍵字),使用columnOverride覆蓋 --> <property name="autoDelimitKeywords" value="true" /> <!-- 生成的Java文件的編碼 --> <property name="javaFileEncoding" value="utf-8" /> <!-- beginningDelimiter和endingDelimiter:指明數(shù)據(jù)庫的用于標記數(shù)據(jù)庫對象名的符號,比如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}" /> <!-- 類型轉(zhuǎn)換 --> <javaTypeResolver> <!-- 是否使用bigDecimal, false可自動轉(zhuǎn)化以下類型(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可以有多個,每個數(shù)據(jù)庫中的表都可以寫一個table,tableName表示要匹配的數(shù)據(jù)庫表,也可以在tableName屬性中通過使用%通配符來匹配所有數(shù)據(jù)庫表,只有匹配的表才會自動生成文件 --> <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: 進行配置

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


測試陳宮

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

相關文章

  • java中抽象類、抽象方法、接口與實現(xiàn)接口實例詳解

    java中抽象類、抽象方法、接口與實現(xiàn)接口實例詳解

    這篇文章主要給大家介紹了關于java中抽象類、抽象方法、接口與實現(xiàn)接口的相關資料,文中通過示例代碼將四者介紹的非常詳細,并且簡單介紹了抽象類和接口的區(qū)別,需要的朋友可以參考借鑒,下面隨著小編來一起學習學習吧。
    2017-11-11
  • 一文詳細springboot實現(xiàn)MySQL數(shù)據(jù)庫的整合步驟

    一文詳細springboot實現(xiàn)MySQL數(shù)據(jù)庫的整合步驟

    Spring Boot可以很方便地與MySQL數(shù)據(jù)庫進行整合,下面這篇文章主要給大家介紹了關于springboot實現(xiàn)MySQL數(shù)據(jù)庫的整合步驟,文中通過圖文以及代碼介紹的非常詳細,需要的朋友可以參考下
    2024-03-03
  • 深入理解Java中的并發(fā)工具類CountDownLatch

    深入理解Java中的并發(fā)工具類CountDownLatch

    CountDownLatch?作為?Java?中的一個同步工具類,用于在多線程間實現(xiàn)協(xié)調(diào)和控制,本文主要來和大家講解一下JUC?工具類?CountDownLatch的使用,需要的可以參考一下
    2023-07-07
  • 詳解Java編程中線程的掛起、恢復和終止的方法

    詳解Java編程中線程的掛起、恢復和終止的方法

    這篇文章主要介紹了詳解Java編程中線程的掛起、恢復和終止的方法,線程是Java學習中的重點和難點知識,需要的朋友可以參考下
    2015-09-09
  • SpringBoot整合gateway全過程

    SpringBoot整合gateway全過程

    這篇文章主要介紹了SpringBoot整合gateway全過程,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • Java中四種訪問控制權限解析(private、default、protected、public)

    Java中四種訪問控制權限解析(private、default、protected、public)

    java當中有4種訪問修飾限定符privat、default(默認訪問權限),protected以及public,本文就詳細的介紹一下這四種方法的具體使用,感興趣的可以了解一下
    2023-05-05
  • Java導出Excel通用工具類實例代碼

    Java導出Excel通用工具類實例代碼

    這篇文章主要給大家介紹了關于Java導出Excel通用工具類的相關資料,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-04-04
  • 深入了解java8的foreach循環(huán)

    深入了解java8的foreach循環(huán)

    雖然java8出來很久了,但是之前用的一直也不多,最近正好學習了java8。下面給大家分享java8中的foreach循環(huán),感興趣的朋友一起看看吧
    2017-05-05
  • SpringBoot常見錯誤圖文總結(jié)

    SpringBoot常見錯誤圖文總結(jié)

    最近在使用idea+Springboot開發(fā)項目中遇到一些問題,這篇文章主要給大家介紹了關于SpringBoot常見錯誤總結(jié)的相關資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-06-06
  • IDEA 2020 無法啟動的解決辦法(啟動崩盤)附IDEA 2020 新功能

    IDEA 2020 無法啟動的解決辦法(啟動崩盤)附IDEA 2020 新功能

    這篇文章主要介紹了IDEA 2020 無法啟動的解決辦法(啟動崩盤)附IDEA 2020 新功能,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-04-04

最新評論