MyBatisx代码生成

 MyBatisx代码生成

1.创建数据库表

CREATE TABLE `sys_good` (
  `good_id` int(11) NOT NULL,
  `good_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `good_desc` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  PRIMARY KEY (`good_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

2.idea中下载插件

3.idea中连接数据库

4.导入基本的依赖

    <dependencies>
        <!--        spring-web-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- MySQL 驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.22</version>
        </dependency>
        <!--        mybatis-plus-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.2</version>
        </dependency>
    </dependencies>

5.生成代码

6.代码生成后

在mapper层加上对应的注解就可以。

猜你喜欢

转载自blog.csdn.net/weixin_41957626/article/details/132587593