Preface
Idea is the second girlfriend of our programmers. We have to make it very smart in order to work more efficiently. So here are some very useful plugins to make our idea more efficient and easy to use. .
一、Material Theme UI
You can change the original appearance to the Material Design appearance, and the idea interface after using it becomes very beautiful, the mood is good, and the code writing speed becomes faster.
二、GenerateAllSetter
This is to help us generate all the set methods of the object with one click. We don't need to manually write the set one by one. If an object has more than ten or more than twenty properties, it is really not too cool to use.
、 、 Properties to YAML Converter
This is to convert the properties file in the project into a yaml file. Before spring boot is used, most of the configuration files are in the properties format. After only using spring boot, it is recommended to use the yaml file. At this time, format conversion is required, and only one Seconds
Four, MyBatis plugin
Willful jump between mapper.java and mapper.xml. Click the small arrow to jump.
Five, Lombok
In the past Java projects, there were too many unfriendly codes: POJO's getter/setter/toString; exception handling; I/O stream closing operations, etc. These boilerplate codes have no technical content and affect the code Beautiful, Lombok came into being. It makes the code very concise.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>版本号</version>
<scope>provided</scope>
</dependency>
Six, Ali code protocol detection
Alibaba Java Coding Guidelines
Manual investigation of optimized code always seems uneasy, so I found a lot of plug-ins on the Internet. Here I recommend an artifact from Ali’s Alibaba Development Convention. He will give fatal errors, errors, warnings and other levels according to your code situation, allowing programmers to quickly locate the problem code and modify it.
Seven, maven helper
In daily work, sometimes we will not pay attention to introducing conflicting packages. Some imported packages rely on other packages, which may cause package conflicts and cause our program to report errors. This plug-in helps us to detect which packages are occurring. Conflict.
Eight, GsonFormat
json is a very popular format at present, but it needs to be formatted into a standardized format to have better readability. Then this plug-in is to format the messy json data, format it very neatly, and customize a javaBean (without any content) , Just an empty class)
Steps:
- Copy the json you want to parse
- Then alt+insert pops up the following interface or use the shortcut key alt+s
- Call up the plugin by shortcut
九、sequenceDiagram
Sometimes we need to sort out business logic or read the source code. We need to understand the entire call link, and reverse generation of UML sequence diagrams is a strong requirement. This plug-in is for this purpose.
Insert picture description here
十、Rainbow Brackets
This plug-in can achieve the same color of matching brackets, and the function of highlighting the selected area code.
11. Restfultoolkit
When troubleshooting restful interface problems, we usually use command + shift + F [Windows: ctrl+shift+F] to find the corresponding RequestMapping, and our request URL is composed of the RequestMapping of the class and the RequestMapping of the method. It is not very convenient to find it. The RestfulToolkit plug-in can easily find the corresponding URL. The renderings are as follows:
shortcut key Alt + \ (note the backslash here)
interface test
RestfulToolkit also provides a powerful function, it will automatically generate request data according to the method provided by our controller. That is much more convenient when we use postman to test the interface.
The effect is as follows:
12. Codota
Function introduction:
automatic completion of the entire line of code.
Based on the massive amount of Java code and your code context, the entire line of code suggestions are given to help you write code faster and with fewer errors.
Search for similar code examples
If you need some API usage examples. Codota can help you search for the best code examples based on the code context.
Use example one:
The small green icons are provided by the Codota plugin. The following ones are built in IDEA, and there are percentages for reference
Open the sample page
Click Add
Use example two:
Thirteen, anyrule regular plugin
any-rule maintains a collection of commonly used regular expressions, and itself is a regular expression tool that supports Web/VS Code/idea/Alfred Workflow multiple platforms.
Just enter the type of regular expression you need, such as ID card. You see, there are 1 generation 15-digit ID number regular expressions, 2 generation 18-digit ID number regular expressions, and there are also regular expressions that support both 1 and 2 generation numbers. Select the one you want and press back. The car key can be:
(If it is a window system, the shortcut key is alt + a), but it should be noted that anyrule generates javascript regular expressions, if you need to use Java. Need to remove the first and last "/".
14. Grep Console
Since Intellij idea does not support the display of ascii colors, the grep-console plug-in can solve this problem well. You can set the font color and background color of different levels of log.
After customizing the settings, you can run the project to see the effect
15. GitToolBox
Used with the version control tool git, it is very intuitive to display the current project branch, and the number of codes that have not been updated or submitted. Save unnecessary troubles such as query branch and latest code, as shown below:
16. JRebel hot loading plug-in, super awesome
Introduction
JRebel is a set of JavaEE development tools.
Jrebel can quickly implement hot deployment, save a lot of restart time, and improve personal development efficiency.
JRebel is a JAVA virtual machine plug-in, which enables JAVA programmers to instantly see the impact of code changes on an application without redeploying. JRebel enables you to see the changes in code, classes, and resources in real time. You can upload them one by one instead of deploying them all at once. When programmers modify any class or resource in the development environment, this change will be directly reflected in the deployed application, thus skipping the process of construction and deployment, which can save a lot of time for deployment .
JRebel is a JVM plug-in, which takes effect immediately without restarting the system after Java code modification.
IDEA does not natively support hot deployment. Generally, after updating the Java file, you must manually restart the Tomcat server for it to take effect, wasting time and life.
At present, the best solution for hot deployment of ideas is to install the JRebel plugin.
installation
Step 1: Install the plugin
Step 2: Online GUID address: Generate GUID
URL online : Online GUID address
If it fails, refresh the GUID and replace it!
Server address: https://jrebel.qekang.com/{GUID}
Step 3: Open the jrebel panel as shown below and select Connect to online licensing service
After the installation is successful, you can start the project through JRebel. After modifying the Java code in this way, you can use the shortcut key Ctrl+shift+F9 instead of the tedious and time-consuming operation of restarting the site.
Related settings
Set to offline working mode
Set up automatic compilation
To achieve hot deployment, you first need to set up Intellij as follows:
- Since JRebel monitors the changes of class files in real time to achieve hot deployment, it is necessary to turn on the automatic mutation function in the idea environment to achieve modification at any time and take effect at any time.
- Open runtime compilation
设置compiler.automake.allow.when.app.running
Shortcut key ctrl+shift+A, search: registry
or
press shortcut key Ctrl+Shift+Alt+/, select Registry
use
When running the project, click the button in the red box in the figure to run:
The first button is Run and the second button is Debug.
After modifying the code (only testing the modification of the Java code), press the shortcut key Ctrl + Shift + F9. After running, it will prompt whether there are changes to reload, select yes. After loading, the hot update effect has been achieved.
Seventeen, GenerateO2O
You need to define a function, the parameter is the class to be converted, the return value is the type to be converted to, and then use generateO2O to automatically get the set attribute for you.
You can define a special conversion class, such as ScheduleConverter to put the conversion code here, on the one hand to facilitate reuse, on the other hand, to avoid the conversion class occupying a lot of space for logic classes. Of course you can use MapStruct.
(In addition, it is strongly recommended not to use class conversion tools. Modifying attributes is not easy to perceive and easy to bug!!)
18. PlantUML
Recently, the project uses IntelliJ IDEA as the back-end development IDE tool, and needs to use UML to do some design. I recommend this to everyone
19. FindBugs
Programmers always want to avoid writing bugs as much as possible. FindBugs, as a static code checking plug-in, can check hidden dangers in your code and give reasons.
Twenty, MyBatisCodeHelperPro is super awesome
Support mapper mutual jump, automatic method generation, automatic code generation
Instructions for use
The official version is a paid version, the following is the cracked version:
Link: Baidu Cloud Download
Extraction Code: 311r
- Install the plugin locally in IDEA
- Activation method (since 2.8.2): IDEA top menu: Tools -> MybatisCodeHelper -> Activation -> OfflineActivation, enter any string in the offline key box
- Activation method (old): IDEA top menu: Tools -> MybatisCodeHelper -> offlineActivation, enter any string
Configuration
The tinyInt or smallInt used by the database to generate java types are byte and short. It is troublesome to manipulate byte and short types in java code, and often requires forced conversion. The following is to set the use of Integer to replace byte and short and use Java8 date and time types
use
Maven dependency
Create a Maven project, to ensure that the generated code does not show C error prompts, import dependencies:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.11</version>
</dependency>
<!-- 保证生成的Service层的注解不错 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.1.RELEASE</version>
</dependency>
Generate table sql based on entity class
SQL statement
generated by alt+insert : After the table building statement is generated, it is executed in the database, and then the crud code is generated from the database
Generate Bean, Dao+mapper and Service according to the table
Step 1: Connect to the MySQL database in Intellij, right-click on the specified table
Step 2: Configure the generated information
Description:
exampleQuery: A lot of example files will be generated. The example code in xml looks messy. It is recommended to use method name to generate sql instead.
It is not recommended to inherit the mapper interface, so do not select the baseClass option. Now the code is automatically generated, and mapper inheritance can only reduce the amount of code, and the efficiency is not obvious. After inheritance, it becomes more troublesome to look at the xml corresponding to the mapper interface. It is also more difficult to define which methods should be put in the inheritance. It is possible that some methods of interface inheritance are not used at all. The suggestion is that each interface only generates the xml method it needs.
The -generatedComments option is recommended to be selected, otherwise the following prompt will appear.
Step 3: View each generated directory
Generate the corresponding mapper according to the method name in the interface
Only a method name is needed, no parameters and return value are needed. After entering the method name, press alt+enter–Generate mybatis sql to generate the
method name. Support if test when generating sql
Add @param annotation with one click
Press alt+enter
result:
Generate unused fields in resultMap in mapper mapping file
Place the cursor on the type attribute value of the resultmap tag -> alt + enter -> generate unUsed properties
result:
Generate mapper mapping file according to the mapper interface
Create an interface -> place the cursor on the interface name -> alt + enter -> generate mybatis mapper for current class -> select the mapper mapping file location
Generate find method
Generate sql code directly according to the method name. The method name automatically prompts the code for single table operation. Only write a method name.
Find method
Generate update method
Generate delete method
Generate count method
Generate test cases
Generate pagination query (depends on pageHelper)
In the DeptServiceImpl class, you can view the code with paging function just generated.
Export java insert statement from table data
Can be used to quickly construct test data
Rules for method names in Dao
find method
You can use select query get to replace the beginning of find, support orderBy, distinct, findFirst
update method
You can use modify to replace the beginning of update
delete method
You can use remove instead of delete at the beginning
count method
Support distinct