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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

-- ----------------------------

-- 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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

<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

1

2

3

4

5

6

7

8

9

10

11

12

13

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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

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)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Is the company's security software causing the application to fail to run? How to troubleshoot and solve it? Apr 19, 2025 pm 04:51 PM

Troubleshooting and solutions to the company's security software that causes some applications to not function properly. Many companies will deploy security software in order to ensure internal network security. ...

How do I convert names to numbers to implement sorting and maintain consistency in groups? How do I convert names to numbers to implement sorting and maintain consistency in groups? Apr 19, 2025 pm 11:30 PM

Solutions to convert names to numbers to implement sorting In many application scenarios, users may need to sort in groups, especially in one...

How to simplify field mapping issues in system docking using MapStruct? How to simplify field mapping issues in system docking using MapStruct? Apr 19, 2025 pm 06:21 PM

Field mapping processing in system docking often encounters a difficult problem when performing system docking: how to effectively map the interface fields of system A...

How to elegantly obtain entity class variable names to build database query conditions? How to elegantly obtain entity class variable names to build database query conditions? Apr 19, 2025 pm 11:42 PM

When using MyBatis-Plus or other ORM frameworks for database operations, it is often necessary to construct query conditions based on the attribute name of the entity class. If you manually every time...

How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? How does IntelliJ IDEA identify the port number of a Spring Boot project without outputting a log? Apr 19, 2025 pm 11:45 PM

Start Spring using IntelliJIDEAUltimate version...

How to safely convert Java objects to arrays? How to safely convert Java objects to arrays? Apr 19, 2025 pm 11:33 PM

Conversion of Java Objects and Arrays: In-depth discussion of the risks and correct methods of cast type conversion Many Java beginners will encounter the conversion of an object into an array...

E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? E-commerce platform SKU and SPU database design: How to take into account both user-defined attributes and attributeless products? Apr 19, 2025 pm 11:27 PM

Detailed explanation of the design of SKU and SPU tables on e-commerce platforms This article will discuss the database design issues of SKU and SPU in e-commerce platforms, especially how to deal with user-defined sales...

How to use the Redis cache solution to efficiently realize the requirements of product ranking list? How to use the Redis cache solution to efficiently realize the requirements of product ranking list? Apr 19, 2025 pm 11:36 PM

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

See all articles