Bugs encountered when using mybatis-generator with mysql8.0.3 in IDEA

Bugs encountered when using mybatis-generator with mysql8.0.3 in IDEA

1. Add the plug-in and add the following configuration under the pom file

<!-- mybatis-generator -->
  <plugin>
  <groupId>org.mybatis.generator</groupId>
  <artifactId>mybatis-generator-maven-plugin</artifactId>
  <version>1.3.5</version>
  <configuration>
   <configurationFile>
   <!--Here is the path to configure generatorConfig.xml. If it is not specified, the generatorConfig.xml file will be found in the resources directory by default. -->
   </configurationFile>
   <verbose>true</verbose>
   <overwrite>true</overwrite>
  </configuration>
  <dependencies>
   <dependency>
   <groupId>mysql</groupId>
   <artifactId>mysql-connector-java</artifactId>
   <version>8.0.11</version>
   </dependency>
  </dependencies>
  </plugin>

2. Create generatorConfig.xml under resources with the following content:

<?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>
 <!-- context is the main configuration information for reverse engineering -->
 <!-- id: give it a name-->
 <!-- targetRuntime: Set the generated file to apply to that mybatis version -->
 <context id="default" targetRuntime="MyBatis3">
 <!--optional, refers to controlling comments when creating a class-->
 <commentGenerator>
  <property name="suppressDate" value="true"/>
  <!-- Whether to remove automatically generated comments true: yes: false: no -->
  <property name="suppressAllComments" value="true"/>
 </commentGenerator>
 <!--jdbc database connection wg_insert is the database name-->
 <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
   connectionURL="jdbc:mysql://localhost:3306/wg_insert?useUnicode=true&amp;characeterEncoding=utf-8&amp;serverTimezone=UTC" userId="root"
   password="123456"></jdbcConnection>
 <!--Optional, type processor, conversion control between database type and java type-->
 <javaTypeResolver>
  <!-- By default, the decimal and bigInt in the database correspond to the BigDecimal class in sql in Java -->
  <!-- Not double or long type -->
  <!-- Use common basic types instead of reference types under the sql package-->
  <property name="forceBigDecimals" value="false"/>
 </javaTypeResolver>
 <!-- targetPackage: the package where the generated entity class is located -->
 <!-- targetProject: the hard disk location where the generated entity class is located -->
 <javaModelGenerator targetPackage="com.wglvzyx.mybatisredis.entity"
    targetProject="src/main/java">
  <!-- Whether to allow sub-packages -->
  <property name="enableSubPackages" value="false"/>
  <!-- Whether to add a constructor to modal-->
  <property name="constructorBased" value="true"/>
  <!-- Whether to clean up the blank characters on both sides of the string queried from the database -->
  <property name="trimStrings" value="true"/>
  <!-- Establish whether the modal object is immutable, that is, the generated modal object will not have a setter method, only a constructor -->
  <property name="immutable" value="false"/>
 </javaModelGenerator>
 <!-- targetPackage and targetProject: the package and location of the generated mapper file -->
 <sqlMapGenerator targetPackage="mapper"
    targetProject="src/main/resources">
  <!-- For a database configuration, whether to use schema as a subpackage name -->
  <property name="enableSubPackages" value="false"/>
 </sqlMapGenerator>
 <!-- targetPackage and targetProject: the package and location of the generated interface file -->
 <javaClientGenerator type="XMLMAPPER"
    targetPackage="com.wglvzyx.mybatisredis.dao" targetProject="src/main/java">
  <!-- For a configuration of Oracle database, whether to use schema as a subpackage name -->
  <property name="enableSubPackages" value="false"/>
 </javaClientGenerator>
 <!-- tableName is the table name in the database, domainObjectName is the generated JAVA model name, the following parameters do not need to be changed, if you want to generate more tables, continue to add table tags below-->
 <table tableName="student" domainObjectName="Student"
  enableCountByExample="false" enableUpdateByExample="false"
  enableDeleteByExample="false" enableSelectByExample="false"
  selectByExampleQueryId="false"></table>
 </context>
</generatorConfiguration>

3. Run, there are two methods:

Method 1:

Add a "Run" option in Intellij IDEA and use Maven to run the mybatis-generator-maven-plugin plug-in (mybatis-generator:generate -e):

insert image description here

Method 2:

Open the Maven panel on the right, open mybatis-generator:generate under Mybatis-generator under Plugins, right-click Run Maven Build!

insert image description here

Notice:

Because I use mysql-8.0.11

So the configuration is different

The main thing is that the new version has new features. First of all, the latest official support is to change com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver. In addition, mysql8.0 does not need to establish an SSL connection. You need to explicitly turn it off, that is, useSSL=false in the url; finally, you need to set CST, which can be regarded as the standard time of the United States, Australia, Cuba or China. serverTimezone is used to set the time zone. You can check the relevant information to find out more!

jdbc.driverClassName=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mytest?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=UTC
jdbc.username=root
jdbc.password=123456

This is the end of this article about the pitfalls of using mybatis-generator with IDEA and MySQL 8.0.3. For more information about using mybatis-generator with MySQL in IDEA, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • MySQL 8.0.24 version installation and configuration method graphic tutorial
  • Some improvements in MySQL 8.0.24 Release Note
  • Implementation of MySQL's MVCC multi-version concurrency control
  • The best solution for resetting the root password of MySQL 8.0.23
  • About the configuration problem of MyBatis connecting to MySql8.0 version
  • How to solve the problem that Seata cannot use MySQL 8 version
  • Detailed explanation of DBeaver connecting to MySQL version 8 and above and solving possible problems
  • Solution to the garbled code problem in MySQL 5.x
  • Detailed tutorial on installing MySQL 8.0.20 database on CentOS 7
  • Solution to ONLY_FULL_GROUP_BY error in Mysql5.7 and above
  • Solve the installation problem of mysql8.0.19 winx64 version
  • Django 2.2 and PyMySQL version compatibility issues
  • Steps to install MySQL 5.7 in binary mode and optimize the system under Linux
  • Installation of various versions of MySQL 8.0.18 and problems encountered during installation (essence summary)
  • Super detailed teaching on how to upgrade the version of MySQL

<<:  Javascript common higher-order functions details

>>:  In-depth understanding of Vue's plug-in mechanism and installation details

Recommend

HTML table markup tutorial (16): title horizontal alignment attribute ALIGN

By default, the table title is horizontally cente...

The whole process of installing mysql5.7.22 under ARM64 architecture

MySQL download address: https://obs.cn-north-4.my...

Detailed explanation of HTML table inline format

Inline format <colgroup>...</colgroup>...

MySQL learning database search statement DQL Xiaobai chapter

Table of contents 1. Simple retrieval of data 2. ...

The perfect solution to the Chinese garbled characters in mysql6.x under win7

1. Stop the MySQL service in the command line: ne...

Analysis of mysql view functions and usage examples

This article uses examples to illustrate the func...

Pure CSS to achieve the list pull-down effect in the page

You may often see the following effect: That’s ri...

Explain TypeScript enumeration types in detail

Table of contents 1. Digital Enumeration 2. Strin...

Website redesign is a difficult task for every family

<br />Every family has its own problems, and...

The most common declaration merge in TS (interface merge)

Table of contents 1. Merge interface 1.1 Non-func...

Mybatis mysql delete in operation can only delete the first data method

Bugs As shown in the figure, I started to copy th...

Solve the problem of secure_file_priv null

Add secure_file_priv = ' '; then run cmd ...

Reasons why MySQL kill cannot kill threads

Table of contents background Problem Description ...