Table of Contents
3. Configure the connection database in IDEA" >3. Configure the connection database in IDEA
" >4. Start generating code
5、pom.xml" >5、pom.xml
6、Application.yml" >6、Application.yml
Home Java javaTutorial EasyCode: Generate code with one click

EasyCode: Generate code with one click

Jul 26, 2023 pm 05:17 PM
easycode

Easycode is a plug-in of idea, which can directly generate entities, controllers, services, dao, and mappers for data tables without any coding. It is simple and powerful.

1. Installation (EasyCode)

EasyCode: Generate code with one click

I have already installed it here.

It is recommended that you install a plug-in called Lombok.

Lombok can automatically generate constructors, getters/setters, equals, hashcode, and toString methods for properties at compile time through annotations. The magic that happens is that there are no getter and setter methods in the source code, but there are getter and setter methods in the compiled bytecode file.

2. Create a database

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`username` varchar(20) DEFAULT NULL,
`sex` varchar(6) DEFAULT NULL,
`birthday` date DEFAULT NULL,
`address` varchar(20) DEFAULT NULL,
`password` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
SET FOREIGN_KEY_CHECKS = 1;
Copy after login

3. Configure the connection database in IDEA

  • Before this, create a new Springboot project, which should be relatively simple.

  • After building the SpringBoot project, as shown in the figure below, find the Database

    EasyCode: Generate code with one click
  • ## Proceed as shown in the figure below:

    EasyCode: Generate code with one click
  • ##Then fill in the database name, user name, password. Just click OK. In this case, IDEA is ready to connect to the database.

    EasyCode: Generate code with one click

4. Start generating code

  • Find the table you want to generate here, then right-click, and the section shown below will appear.
    EasyCode: Generate code with one click
  • 点击1所示的位置,选择你要将生成的代码放入哪个文件夹中,选择完以后点击OK即可。

    EasyCode: Generate code with one click
  • 勾选你需要生成的代码,点击OK。

    EasyCode: Generate code with one click
  • 这样的话就完成了代码的生成了,生成的代码如下图所示:

    EasyCode: Generate code with one click

5、pom.xml

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <!--热部署-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
        </dependency>

        <!--mybatis-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.2</version>
        </dependency>

        <!-- mysql -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
        </dependency>

        <!--阿里巴巴连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.9</version>
        </dependency>
Copy after login

6、Application.yml

server:
  port: 8089
spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/database?useUnicode=true&characterEncoding=UTF-8
    username: root
    password: 123456
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver

mybatis:
mapper-locations: classpath:/mapper/*Dao.xml
typeAliasesPackage: com.vue.demo.entity
Copy after login

7、启动项目

在启动项目之前,我们需要先修改两个地方。

  • 在dao层加上@mapper注解

    EasyCode: Generate code with one click
  • 在启动类里面加上@MapperScan("com.vue.demo.dao")注解。

    EasyCode: Generate code with one click
  • 启动项目

    EasyCode: Generate code with one click
  • 测试一下

    EasyCode: Generate code with one click
EasyCode: Generate code with one click

The above is the detailed content of EasyCode: Generate code with one click. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How does Java's classloading mechanism work, including different classloaders and their delegation models? How does Java's classloading mechanism work, including different classloaders and their delegation models? Mar 17, 2025 pm 05:35 PM

How does Java's classloading mechanism work, including different classloaders and their delegation models?

Top 4 JavaScript Frameworks in 2025: React, Angular, Vue, Svelte Top 4 JavaScript Frameworks in 2025: React, Angular, Vue, Svelte Mar 07, 2025 pm 06:09 PM

Top 4 JavaScript Frameworks in 2025: React, Angular, Vue, Svelte

How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading? How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading? Mar 17, 2025 pm 05:43 PM

How can I use JPA (Java Persistence API) for object-relational mapping with advanced features like caching and lazy loading?

How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution? How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution? Mar 17, 2025 pm 05:46 PM

How do I use Maven or Gradle for advanced Java project management, build automation, and dependency resolution?

How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache? How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache? Mar 17, 2025 pm 05:44 PM

How do I implement multi-level caching in Java applications using libraries like Caffeine or Guava Cache?

Node.js 20: Key Performance Boosts and New Features Node.js 20: Key Performance Boosts and New Features Mar 07, 2025 pm 06:12 PM

Node.js 20: Key Performance Boosts and New Features

Iceberg: The Future of Data Lake Tables Iceberg: The Future of Data Lake Tables Mar 07, 2025 pm 06:31 PM

Iceberg: The Future of Data Lake Tables

Spring Boot SnakeYAML 2.0 CVE-2022-1471 Issue Fixed Spring Boot SnakeYAML 2.0 CVE-2022-1471 Issue Fixed Mar 07, 2025 pm 05:52 PM

Spring Boot SnakeYAML 2.0 CVE-2022-1471 Issue Fixed

See all articles