This article will talk to you about the 12
plug-ins that can improve coding efficiency in idea
. I hope it will be helpful to everyone.
1. lombok
There was still controversy about lombok before, whether it should be used in the project, so I still I wrote a special article "Confused, should we use lombok?" 》.
Now the new version of idea has built-in lombok plug-in, so using it is a trend.
The reason why I put lombok as the first introduction in the entire article is because it can really help me write a lot less code, especially in entities, DTOs, VOs, and BOs.
We use the User class as an example. Previously, to define a javabean, you needed to write the following code:
public class User { private Long id; private String name; private Integer age; private String address; public User() { } public User(Long id, String name, Integer age, String address) { this.id = id; this.name = name; this.age = age; this.address = address; } public Long getId() { return id; } public String getName() { return name; } public Integer getAge() { return age; } public String getAddress() { return address; } public void setId(Long id) { this.id = id; } public void setName(String name) { this.name = name; } public void setAge(Integer age) { this.age = age; } public void setAddress(String address) { this.address = address; } @Override public boolean equals(Object o) { if (this == o) returntrue; if (o == null || getClass() != o.getClass()) returnfalse; User user = (User) o; return Objects.equals(id, user.id) && Objects.equals(name, user.name) && Objects.equals(age, user.age) && Objects.equals(address, user.address); } @Override public int hashCode() { return Objects.hash(id, name, age, address); } @Override public String toString() { return"User{" + "id=" + id + ", name='" + name + '\'' + ", age=" + age + ", address='" + address + '\'' + '}'; } }
The User class includes: member variables, getter/setter methods, constructor methods, equals, and hashCode methods.
At first glance, there are quite a lot of codes. And there is another question. If the code in the User class is modified, for example: the age field is changed to a string type, or the name field name is modified, does it need to modify the related member variables, getter/setter methods, constructors, etc. simultaneously? Modify all equals and hashCode methods?
The good news is that using lombok can solve this problem.
If it is a version before idea2020.3, you need to install the following plug-in in idea:
But after idea2020.3, idea has built-in lombok function.
With the lombok plug-in, now we can achieve the above functions by writing code like this in idea:
@ToString @EqualsAndHashCode @NoArgsConstructor @AllArgsConstructor @Getter @Setter public class User { private Long id; private String name; private Integer age; private String address; }
It’s so easy, and you can really write a lot less code.
In addition, we also need to introduce lombok's dependency package in the project's pom file, otherwise the project will not run.
2. Free Mybatis plugin
In Chinamybatis
has become the most mainstream database framework, which is semi-automated The ORM persistence framework is more flexible and has higher performance than a fully automated persistence framework like hibernate.
In mybatis
, we need to define the mapper and the corresponding xml file ourselves to complete the binding.
Here we take the user table as an example. First we need to define the UserMapper interface:
public interface UserMapper { int insertUser(UserModel user); }
Then we need the UserMapper.xml configuration file:
<?xml version="1.0" encoding="UTF-8" ?> nbsp;mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper> <sql> id, name, age, sex </sql> <insert> INSERT INTO user <trim> <if> id, </if> <if> name, </if> <if> age, </if> <if> sex, </if> </trim> <trim> <if> #{id}, </if> <if> #{name}, </if> <if> #{age}, </if> <if> #{sex}, </if> </trim> </insert> </mapper>
In the UserMapper.xml file, mapper The namespace of the label corresponds to the UserMapper interface name, and the id of the insert label=insertUser, which corresponds to the insertUser method in the UserMapper interface.
So, how can we quickly access the getUser method in the UserMapper.xml file through the getUser method in the UserMapper class in the project?
Answer: This requires the use of the Free Mybatis plugin
plugin.
After installing the plug-in, there will be two more green arrows to the left of the interface name and method name of the UserMapper interface. Click on the arrow to jump. Go to the mapper tag or insertUser statement corresponding to the UserMapper.xml file.
In addition, there will be an extra green arrow on the left side of the insertUser statement in the UserMapper.xml file. We can also jump to the UserMapper interface by clicking on the arrow. on the insertUser method.
With this plug-in, we can freely switch between mapper and xml, play freely, and no longer have to search like before.
3.Translation
Some friends, including myself, may not be very good at English (I have just passed CET-4).
When we name variables or methods, we have to think about it for a long time. Especially when reading the JDK English documentation, I encountered some uncommon words, which was really confusing.
The good news is that using: Translation
plug-in allows us to fly freely in the document.
After installing the Translation
plug-in, there is an additional Translation menu in other settings.
Click on this menu:
In the window on the right, you can choose the translation software.
Select the English document that needs to be translated:
In the right-click pop-up window, select the Translation option, and the following window will pop up:
An English paragraph was suddenly translated into Chinese. It was so cool.
4.Alibaba Java Coding Guidelines
If you are a friend engaged in Java development, you must have read Alibaba's "Java Development Manual".
This manual summarizes the problems we may encounter in our daily development process. From programming protocols, exception logs, unit tests, security protocols, MySQL database and project structure, these six aspects standardize the development process and ensure that we can write efficient and elegant code.
But these normative things, relying solely on people’s consciousness, are difficult to achieve the expected results.
In order to solve this problem, Alibaba launched the Alibaba Java Coding Guidelines
plug-in, which can directly detect non-standard code.
After installing the plug-in, press the shortcut key: Ctrl Alt Shift J
to scan the entire project or a single file for coding conventions.
After scanning, the non-standard codes will be sorted from high to low.
There are currently three levels shown below:
- Blocker Crash
- Critical
- Major Important
Click on one of the irregular code lines on the left, and the detailed irregular code will be immediately displayed in the window on the right, allowing us to quickly locate the problem.
nice.
5. GenerateAllSetter
Many times, we need to assign a value to an object. If there are many parameters, we need to write a lot of setter
or getter
Code.
Is there any way to do it with one click?
Answer: Yes, use the GenerateAllSetter
plug-in.
After installing the plug-in, press the shortcut key on the created object: alt enter
.
Select in the pop-up window: Generate all setter with default value.
will automatically generate the following code:
It’s so convenient.
6. SequenceDiagram
When we usually read the source code, in order to sort out the internal logic, we often need to draw some sequence diagrams
.
If we draw directly, it will waste a lot of time, and the picture drawn may not be correct.
You can use: SequenceDiagram
plug-in.
Select a specific method, right-click and select: sequence diagram option:
After that, the sequence diagram will appear:
From now on, I can become a master of drawing, perfect.
7. CheckStyle-IDEA
In terms of code format, there are many places that we need to pay attention to, such as: useless imports, no comments, grammatical errors, and too many methods. Long wait.
Is there any way to detect the above problems at once in the idea?
Answer: Use the CheckStyle-IDEA
plug-in.
CheckStyle-IDEA
is a tool to detect whether the code format meets the specifications. The most commonly used ones are the Google
specification and the Sun
specification. .
After installing the plug-in, the CheckStyle option will appear below the idea:
Click the green button on the left , you can scan the code. In the middle, the reason for noncompliance with code specifications is displayed.
Double-click the code to jump directly to the specific code:
8.JRebel and Will run the latest place.
And every restart takes a lot of time. Is there any way to make the Java code modification take effect immediately without restarting the system? Answer: Use theJRebel and XRebel
plug-in.As shown in the picture:
After the installation is completed, there will be two green buttons here, and an additional option Select Rebel Agents on the right:
Select Rebel Agents option contains three values:
JRebel: After modifying the code, do not restart the service, and expect the code to take effect directly.
- XRebel: Monitor the performance of each part of the code during the request process. For example: method execution time, exceptions that occur, SQL execution time, output Log, MQ execution time, etc.
- JRebel XRebel: After modifying the code, do not restart the service and monitor the code.
- 9. Codota
To be honest, the existing code prompt function of idea is already very powerful.
But if you have used theCodota
plug-in, it will make your code writing speed go to the next level.After installing the plug-in, it will give you some tips when we write code:
10. GsonFormat
Many times, I need to convert the parameters in json
intoentity objects parameter. Or convert the parameters in
entity object into parameters in
json.
In the past, we used to manually copy one variable and one variable.
GsonFormat
plug-in can help us accomplish this.After installing the plug-in, first create an empty class:
Press the shortcut key: alt s
Then enter the json data in this window.
11. Rainbow Brackets
When we usually write code, brackets give us a lot of headaches, especially when the code has a lot of logic and is nested layer by layer. .
It is difficult to tell at a glance which bracket the code starts from and which anti-bracket it ends with. Is there any way to solve this problem? Answer: Use theRainbow Brackets
plug-in.
is very conspicuous and intuitive.
12. CodeGlance
Sometimes, we read a lot of code, for example, a class contains many methods and member variables.
Following from top to bottom, bit by bit, will waste a lot of time. So is there any way to quickly find the code you want to see? Answer: Yes, you can use theCodeGlance
plug-in.After installing the plug-in, the following window will appear on the right side of the code:
Finally (please pay attention, don’t prostitute me in vain)
If this article is helpful or inspiring to you, please help scan and send the QR code Pay attention, your support is my biggest motivation to keep writing.
Please click three links: like, retweet, and watching.
Follow the public account: [Su San talks about technology], reply in the public account: Interviews, code artifacts, development manuals, time management have great fan benefits, and reply: Join the group, you can follow many seniors from BAT companies Communicate and learn.
(Learning video sharing: Basic Programming Video)
The above is the detailed content of 12 idea plug-ins to improve your coding efficiency. For more information, please follow other related articles on the PHP Chinese website!

在使用Netty开发WebSocket服务器时,可能会遇到浏览器在尝试连接时未能正确处理服务器返回的401状态码的情况。 �...

Java compilation failed: Running window javac command cannot generate class file Many Java beginners will encounter this problem during the learning process: running window...

Discussing the hierarchical architecture problem in back-end development. In back-end development, common hierarchical architectures include controller, service and dao...

Packages and Directories in Java: The logic behind compiler errors In Java development, you often encounter problems with packages and directories. This article will explore Java in depth...

Leetcode ...

JWT and Session Choice: Tradeoffs under Dynamic Permission Changes Many Beginners on JWT and Session...

How to correctly configure apple-app-site-association file in Baota nginx? Recently, the company's iOS department sent an apple-app-site-association file and...

How to understand the classification and implementation methods of two consistency consensus algorithms? At the protocol level, there has been no new members in the selection of consistency algorithms for many years. ...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 English version
Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.