IDEA懒人插件 EasyCode

  • IDEA插件:https://yuanyu.blog.csdn.net/article/details/104656085
  • MyBatis-Plus【入门】:https://blog.csdn.net/qq_40794973/article/details/90738854

1 IDEA安装EasyCode插件 

IDEA懒人插件 EasyCode_第1张图片


2 创建数据库

docker run \
--name easycode_db \
-e MYSQL_ROOT_HOST=%.%.%.% \
-e MYSQL_ROOT_PASSWORD=123456 \
-p 6033:3306  \
-di mysql:8.0.18

3 IDEA创建SpringBoot项目并连接数据库

jdbc:mysql://ip地址:6033/?serverTimezone=UTC
-- 创建数据库
CREATE DATABASE easycode_db;
USE easycode_db;
-- 创建测试表
CREATE TABLE `user`
(
    `id`       INT(10) UNSIGNED AUTO_INCREMENT COMMENT '主键ID',
    `username` VARCHAR(20) NOT NULL COMMENT '用户名',
    `password` VARCHAR(64) NOT NULL COMMENT '密码',
    `name`     VARCHAR(20) COMMENT '姓名',
    `age`      TINYINT UNSIGNED COMMENT '年龄',
    `email`    VARCHAR(50) COMMENT '邮箱',
    PRIMARY KEY `id` (`id`),
    UNIQUE KEY `uk_user_username` (`username`)
);
-- 插入测试数据
INSERT INTO `user` (`id`, `username`, `password`, `name`, `age`, `email`)
VALUES ('1', 'zhangsan', '123456', '张三', '18', '[email protected]'),
       ('2', 'lisi', '123456', '李四', '20', '[email protected]'),
       ('3', 'wangwu', '123456', '王五', '28', '[email protected]'),
       ('4', 'zhaoliu', '123456', '赵六', '21', '[email protected]'),
       ('5', 'sunqi', '123456', '孙七', '24', '[email protected]');

 


    
        
        
            org.springframework.boot
            spring-boot-dependencies
            2.3.0.RELEASE
            pom
            import
        
    


    UTF-8
    UTF-8
    1.8

    
    
        org.springframework.boot
        spring-boot-starter-web
    
    
        org.springframework.boot
        spring-boot-starter-test
    
    
    
        mysql
        mysql-connector-java
        8.0.18
    
    
        com.alibaba
        druid-spring-boot-starter
        1.1.22
    
    
        com.baomidou
        mybatis-plus-boot-starter
        3.3.1
    
    
    
        org.projectlombok
        lombok
    

4 生成代码

4.1 右键生成代码

IDEA懒人插件 EasyCode_第2张图片

4.2 选择代码放置的位置

IDEA懒人插件 EasyCode_第3张图片


5 运行项目

5.1 修改配置文件

application.yml

spring:
  datasource:
    url: jdbc:mysql://ip地址:6033/easycode_db?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false&allowPublicKeyRetrieval=true
    username: root
    password: 123456
    driver-class-name: com.mysql.cj.jdbc.Driver
    type: com.alibaba.druid.pool.DruidDataSource
logging:
  level:
    cn.yuanyu: debug

5.2 修改生成的Mapper

public interface UserMapper extends BaseMapper {
}
@Data
public class User {
    /**
    * 主键ID
    */
    @TableId(type = IdType.AUTO)
    private Long id;

 5.3 修改启动类 

@SpringBootApplication
@MapperScan("cn.yuanyu.dao")
public class EasycodeApplication {
    public static void main(String[] args) {
        new SpringApplicationBuilder(EasycodeApplication.class)
                .web(WebApplicationType.SERVLET)
                .run(args);
    }
}

 

  • https://www.pianshen.com/article/157753432/
  • https://mp.weixin.qq.com/s/Eq10uFvbBkqnf4E7l788CQ

你可能感兴趣的:(编译器)