12 god-level IDEA plug-ins, allowing you to write 80% less code

Hello everyone, I am flying!

In business function development, in most cases, the core business code only accounts for 20% of the project, and the remaining 80% is basically some physical work, configuration items, etc.; these 80% of the code consumes a lot of our time. However, this part of the code will not bring us a big improvement. Today I recommend 12 high-quality plug-ins that I personally commonly use, aiming to help you quickly complete the 80% physical code and invest more time in the core. For function development, say goodbye to overtime and 996!

Easy Code

One can help us quickly map the table into files such as Entity, Controller, Dervice, Dao, Mapperetc. in the Spring project, and quickly implement basic functions.

Plug-in installation

Search the plug-in center Easy Codefor quick installation

Plug-in usage

The first step is to add a data source and connect to the corresponding database.

Step 2

Find the corresponding table in the data source, right-click and select Easy Codeto quickly generate

Easy Javadoc

A tool class that can quickly help you generate documentation comments for properties, methods, and classes with one click. Document comments can be easily done.

Install

Plug-in center searchEasy Javadoc

The plug-in requires online translation. The following is the application entrance for each platform's API key. You can apply for the corresponding key according to your preference. For personal use, the monthly free quota can basically be satisfied.

  • Youdao Zhiyun translation application address: https://ai.youdao.com/
  • Baidu Translation application address: https://api.fanyi.baidu.com/doc/21
  • Tencent translation application address: https://cloud.tencent.com/document/product/551/7372
  • Alibaba Cloud Translation application address: https://www.aliyun.com/product/ai/alimt
  • Microsoft Translator application address: https://azure.microsoft.com/
  • Google Translate (requires magic) application address: https://cloud.google.com/

Configuration

Find the configuration interface in file -> settings -> other settings - EasyDocand configure the translated api key (required), custom vocabulary mapping (optional), and template information (optional)

win shortcut key

shortcut key Scope illustrate
ctrl \ Classes, methods, properties (just put the cursor on them, don’t double-click to select!) Generate comments for the current documentation
ctrl \ Selected Chinese Generate English names for the selected Chinese characters
ctrl \ Selected non-Chinese Pop-up box displays translation results
ctrl shift \ kind Generate all documentation comments

mac shortcut keys

shortcut key Scope illustrate
command \ Classes, methods, properties (just put the cursor on them, don’t double-click to select!) Generate comments for the current documentation
command \ Selected Chinese Generate English names for the selected Chinese characters
command \ Selected non-Chinese Pop-up box displays translation results
command shift \ kind Generate all documentation comments

Among them, "dashabi" uses the custom "cutie" mapping

Problem statement

  • Not translated

    After pressing the shortcut key, only the following empty comment was generated

    /**
    *
    **/
    

    It’s just that the translation configuration has not taken effect. You can go to each translation platform to apply for the API key and configure it.

  • Shortcut key is invalid

    The shortcut key may be occupied by other software. You can Settings -> Keymap -> Plug-ins -> Easy Javadocfind and set a new shortcut key in

Small

A very practical intelligent chatbot plug-in that integrates GPT, which can provide developers with a faster and more accurate interactive programming environment. It can be used without magic and can greatly improve development efficiency. I have recommended it to everyone before. Details For usage tutorials, please refer to: IDEA uses this free GPT4 plug-in to increase productivity.

aiXcoder

The first domestic intelligent software development tool based on deep learning, which uses AI technology to realize functions such as automatic code generation, automatic code completion, and intelligent code search, improving developer development efficiency and code quality.

Install

use

  • Turn on cloud service

    Here you need to register an account, log in, follow the prompts and operate step by step.

  • code completion

Lombok

Lombok is a compile-time plug-in for the Java language. It is used to automatically generate repetitive code through annotations and reduce some conventional Java code writing.

rely

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.26</version>
</dependency>

plug-in

Lombok not only requires dependencies, but also requires the installation of corresponding plug-ins. Search for Lombok in the plug-in center , install and restart

use

Before using Lombok, it was very troublesome to write an object's get, set, tostring, construction methods, etc. For a simple object, you need to write the following code:

/**
 * @author 公众号:一行Java
 * @title: UserInfo
 * @projectName ehang-spring-boot
 * @description: TODO
 * @date 2023/9/15 9:15
 */
public class UserInfo {
    
    

    private String userName;
    
    private Integer age;

    public UserInfo() {
    
    
    }

    public UserInfo(String userName, Integer age) {
    
    
        this.userName = userName;
        this.age = age;
    }

    public String getUserName() {
    
    
        return userName;
    }

    public void setUserName(String userName) {
    
    
        this.userName = userName;
    }

    public Integer getAge() {
    
    
        return age;
    }

    public void setAge(Integer age) {
    
    
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
    
    
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        UserInfo userInfo = (UserInfo) o;

        return new EqualsBuilder()
                .append(userName, userInfo.userName)
                .append(age, userInfo.age)
                .isEquals();
    }

    @Override
    public int hashCode() {
    
    
        return new HashCodeBuilder(17, 37)
                .append(userName)
                .append(age)
                .toHashCode();
    }

    @Override
    public String toString() {
    
    
        return "UserInfo{" +
                "userName='" + userName + '\'' +
                ", age=" + age +
                '}';
    }
}

But once Lombok is introduced, this matter becomes very simple. Three annotations can implement all the above methods, and the code becomes very concise and refreshing;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 公众号:一行Java
 * @title: UserInfo
 * @projectName ehang-spring-boot
 * @description: TODO
 * @date 2023/9/15 9:15
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserInfo {
    
    

    private String userName;

    private Integer age;

}

Annotations and instructions supported by Lombok

  1. @Getter/ @Setter: Automatically generate the getter and setter methods of the field.
  2. @ToString: Automatically generate toString method. By default, the toString method is generated for all fields.
  3. @EqualsAndHashcode: Automatically generate equals and hashCode methods. By default, equals and hashCode methods are generated that include all non-static, non-transient fields.
  4. @NoArgsConstructor/ @RequiredArgsConstructor/ @AllArgsConstructor: Automatically generate no-parameter construction method, required parameter construction method, and full-parameter construction method.
  5. @Data: Automatically generate getter, setter, equals, hashCode, and toString methods.
  6. @Builder: Automatically generate builder pattern code for creating complex objects.
  7. @Log: Automatically generate logging variables to support different logging frameworks, such as @Slf4jfor integrating SLF4J.
  8. @NoArgsConstructor(force = true)/ @AllArgsConstructor(force = true): Automatically generate no-parameter constructor and full-parameter constructor, and set the field to final.
  9. @Cleanup: Automatically manage resources, mainly used to clear resources that need to be released manually, such as IO streams.
  10. @SneakyThrows: Automatically catch and rethrow exceptions in the method body without explicit exception handling.
  11. @NonNull: Generate non-empty check code.
  12. @Accessors: Provide chain call style setter and getter methods.
  13. @Value: Create an immutable class with final fields and automatically generate getter methods.
  14. @Wither: Immutable update method for automatically generated properties.
  15. @EqualsAndHashCode(callSuper = true): Generate equals and hashCode methods containing parent class fields.

Lombok is disabled

When your company/team bans the use of Lombok plug-ins and only allows you to use traditional methods to write basic methods such as get, set, and toString, is there a way to quickly generate these tedious manual tasks? IDEA has actually built-in the function for us to quickly generate these methods;

Press shortcut keyAlt + Insert

Or right-click the object and selectGenerate...

Select the content you want to generate and you can quickly generate the corresponding method.

GsonFormatPlus

A plug-in for quickly converting Json into Java objects; most of the current systems, front-end and back-end interactions use Json, so when parsing Json, an object is needed to accept it. Using this tool, you can You can quickly generate a Java object for acceptance through Json text, eliminating the tedious physical effort of manually typing attributes one by one;

Install plugin

Search in the plug-in center GsonFormatPlusand install it;

use

Use shortcut keys:Alt + S

Or use Alt + Insertand selectGsonFormatPlus

Or, right-click the object, select Generate, and then selectGsonFormatPlus

Paste the Json text on the left, click OK, select the attributes to be generated, and the next step is complete.

GenerateAllSetter

A plug-in that calls set and get methods with one click; when you encounter a large object that needs to be initialized during development, or you want to obtain the properties of a large object, you can simply call its get and set methods, and you can write We are soft-handed, and this plug-in can perfectly help us solve this physical task.

Plug-in installation

Plug-in usage

  • Call set and get methods with one click

    First, place the mouse cursor on the row where the object is located

    Then use the shortcut keys Alt + Enterto choose whether to generate a get or a set. There are several ways to generate a set. One is to not assign a value, and the other is to assign a default value to the attribute. You can decide according to your actual situation:

  • Convert objects with one click

    When we need to do object conversion, for example, converting model objects into DTO objects, we can also use this plug-in to generate them with one click

String Manipulation

In daily development, String is the most frequently used data type. The String Manipulation plug-in can help us quickly complete String conversion, such as: case switching, sorting, incrementing, escaping, encoding, etc. It also supports various encryption and decryption (MD5, Base64, etc.) operations on strings; basically includes all commonly used String operations.

Install

shortcut key

Alt + m

use

The following are examples of camel case naming conversion, encryption and decryption, and case conversion

There are more functions that you can choose according to your needs.

Restfultoolkit

A set of RESTful service development auxiliary tools, a perfect replacement for Postman; interface testing can be completed in IDEA, and interfaces can be quickly searched, greatly improving our retrieval and testing efficiency.

Install

Search the plug-in center Restfultoolkitfor quick installation

shortcut key

Ctrl + Alt + N

use

  • Quick search interface

    When there is a bug, back-end developers may often need to find the interface location based on the interface name/address. The global search searches Ctrl + Shift + Rfor all content, and it is quite troublesome to filter out the desired content; if it is code written by oneself , it is still acceptable to find. Once the project is large and the code is unfamiliar, it is like finding a needle in a haystack; then you can use this tool to quickly search for interfaces and shortcut keys:Ctrl + Alt + N

  • Interface testing

    The menu on the right contains all interfaces in the project. You can directly edit the request object and quickly initiate interface testing.

  • Object to Json

    Earlier we introduced how to convert Json strings into Java objects. With this plug-in, you can quickly convert objects into Json text strings.

Key promoter X

Back then, when converting from Eclipse to IDEA, shortcut keys were one of the biggest obstacles; being able to use shortcut keys flexibly will greatly improve coding efficiency; it is a plug-in that can help Key promoter Xmemorize shortcut keys.

Install

Key promoter XJust search in the plug-in center

Effect

When you do not use Express to operate a certain function, the plug-in will remind you what the corresponding shortcut key is.

Free Mybatis plugin

A plug-in that helps us jump between Mapper and xml in MyBatis

Install

Plug-in center searchFree Mybatis plugin

use


If you are proficient in using these 12 plug-ins, I believe that everyone’s development efficiency will definitely make a qualitative leap...

Supongo que te gusta

Origin blog.csdn.net/lupengfei1009/article/details/132994829
Recomendado
Clasificación