use
Download the mybatis-generater-demo project and configure the generatorConfig file. Generate pojo, xml, mapper.
After successful generation, copy the corresponding file to the correct project location. Add project dependencies
<!-- 通用mapper逆向工具 -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
Some problems with MySQL8
- Modify the database driver com.mysql.cj.jdbc.Driver
- The link address should add the time zone jdbc:mysql://localhost:3306/foodie-shop-dev?serverTimezone=UTC
- Modify the driver version 8.0.20 in the pom
- There is a table with the same name, which causes multiple resultMaps to be generated in the XML file. Add the nullCatalogMeansCurrent attribute.
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/foodie_dev?serverTimezone=UTC"
userId="root"
password="123456">
<property name="nullCatalogMeansCurrent" value="true" />
</jdbcConnection>