IntelliJ idea detailed configuration and use tutorials (for Java Developers) __ development tools

Source: Internet
Author: User
Tags change settings error code
Preface

The so-called 工欲善其事 its prerequisite, for developers to improve the coding efficiency, an efficient development tool is essential, I believe that the blog to see the friends have been understanding of the IntelliJ idea, so this is not the IntelliJ thought to introduce, Instead, it directly describes the application scenarios in actual development. Bloggers Use the IntelliJ idea version of IntelliJ idea 2017, because the blogger is a Java development engineer, so the following content is Java-oriented. (I believe there are a lot of people like me from Eclipse IntelliJ idea, please try to forget about eclipse before learning IntelliJ idea) in the learning process, the main reference https://github.com/judasn/ Intellij-idea-tutorial, this tutorial on the IntelliJ idea Introduction is very detailed, you can directly click on the link above to learn. As for why I write this blog, my goal is to make a record of my personalized configuration, of course, if at the same time can help other people, it is not beautiful, this article will continue to update, because the content of this article more recommended readers from the directory tree to locate the configuration information you want to get off IntelliJ

Cancel automatically check updates for checkmark under File->settings->appearance & Behavior->system settings->updates
hide. Idea folders and. iml files

The IntelliJ idea Project automatically generates an. idea folder and a. iML, looking really unsightly, so the above files are hidden processing
Add *.idea;*.iml to the "Ignore Files and Folders" column under File->settings->editor->file types, as shown in the following figure
Code Editor Theme style

Editor style modification individuals are not recommended entirely by themselves to configure, because the Internet provides a lot of excellent theme style, we can import their favorite theme, and then on its basis for fine-tuning, recommend the theme download site http://www.riaway.com, installation download topic steps:

1. Open your editor from the main menu select File->import Setting. Select the jar file you downloaded;
2. Wait for reboot after the configuration to open file->settings->editor->colors and fonts and then select the theme you installed to complete;

Set the first and second fonts, and modify the font size:
To download the corresponding fonts on the Internet after the installation restart IntelliJ idea, under the main menu to choose File->settings->editor->colors & Fonts-> Font
Show only monospaced fonts indicates that filtering displays equal-width fonts on the system, because the Windows system is not a good wide font, check this option appears a Drop-down font can be selected, uncheck, you can display all installed fonts on the system. I am recommended by the tutorial configuration, English font selection Monaco, this font does not support Chinese, so this is set to the first font, the second font using Yahei Consolas Hybrid, the font contains Chinese. Font size I was modified to 20, configured as shown in the following illustration:

The console output font is similar to the one described above (the console output is garbled by the configuration font resolution) file encoding settings

File->settings->editor->file Encodings

Recommended settings

Global encoding:utf-8
projectt encoding:utf-8
Default Encoding for properties files:utf-8
Check Transparent NATIVE-TO-ASCII Conversion

The transparent Native-to-ascii conversion property is mainly used for converting ASCII, otherwise the Chinese of the properties file will be transcoding, IntelliJ idea in addition to supporting the entire project Setup code, Encoding settings for directories and files are also supported. If you want to encode the directory to set up, you may need to convert the code of the pop-up operation options, it is strongly recommended before the conversion to do a good file backup, or the conversion process may become garbled, can not be restored. The encoding of individual files can also be clicked on the lower right corner of the coding Settings area, if the code content contains Chinese, it pops up the action selections in the demo, Reload says reload with the new encoding, the new encoding is not saved to the file, the file is reopened, what the old code is still, Convert Represents the conversion using a new code, which is saved to a file, reopened, and what the new encoding is. The personal encoding configuration is shown in the following illustration:
class and method annotation templates

1. Modify Class Annotation Template
In File->settings->editor->file and Code templates, respectively, modify the annotation template Class,interface,enum, the class template section is modified as follows, the remaining extrapolate to modify. The ${description} shown below is a custom variable that requests input when the class is created

/**
  * Copyright (C), 2015-${year}, XXX Co., Ltd.
  * FileName: ${name}
  * Author:   ${user}
  * Date:     ${ DATE} ${time}
  * Description: ${description}
  * History:
  * <author>          <time>          < version>          <desc>
  * Author name           modification time           version number              description
  *
/#if (${package_name} && ${package_name}!= "")
    PACKAGE ${package_name};
A brief comment on the function of the #end

/**
 *〈 〉<br> 
 *〈${description}〉 * *
 @author ${user}
 * @create ${date
 * @since 1.0.0 */public
class ${name} {

}

class annotation Template modification configuration diagram

class annotation Template Modification effect chart

2. Method Annotation Template Modification
Add a custom template group under File->settings->editor->live and add a custom template under the custom template group, as shown in the following illustration

Detailed configuration parameters

Template text reads as follows:
/**
 * Function Description: <br>
 *〈 $END $〉
 *
 $param $
 * @return: $return $
 * @ since:1.0.0
 * @Author: $user $
 * @Date: $DATE $ $TIME $ */

Edit Template variables request parameters are as follows:
Groovyscript ("Def result="; def params=\ "${_1}\". ReplaceAll (' [\\\\[|\\\\]|\\\\s] ', '). Split (', '). ToList (); for (i = 0; i < params.size (); i++) {result+= ' * @param ' + params[i] + ((I < Params.size ()-1)? ' \\n ': ')}; return result ", Methodparameters ())

After completing the configuration as above, you can generate annotations simply by executing the/**+enter key within the method, remembering that this is the internal method, because the scope of methodparameters () is only within the method, which is also intellij idea compared to the pain of the egg, Bloggers looking for a long time on the internet did not find a good solution, the network also recommended the use of Javadoc plug-ins to generate comments, interested friends can also try

method annotation Template Modification effect chart
Code Formatting

The shortcut key for code formatting is ctrl+alt+l, and if code is formatted in the class, the code is typeset, and if the focus is on the class or folder, the formatting options prompt box pops up, and the pop-up box looks like this:

Include subdirectories: Whether the subdirectory is also formatted
Optimize imports: Optimize imported classes and packages
rearrange enries: Adjust code order (put filed in front of method)

filters A filter condition that indicates which files are formatted
automatically import all packages

In IntelliJ idea you can only import a single package at a time, there is no shortcut key ctrl+shift+o like the Eclipse Quick Import package, but IntelliJ idea has a feature that automatically imports the package. Configured under File->settings->editor->general->auto import, as shown in the following:

Insert imports on paste: an option to ask if an imported package needs to be queried when the code is copied.
    ask (when you need to import the name of the package will play a prompt box, asked if you want to import)
    NONE (with the package name you want to import will not balloon and will not be imported automatically) all
    (when you need to import the package name will be automatically imported, do not pop-up balloon) show
Import popup: When the declaration of the input class is not imported, a selected dialog box pops up
Optimize imports on Fly: Automatically optimize package import, remove unwanted packages
Add unambiguous imports on the fly: This is the automatic import feature, and when you enter the class name the declaration is automatically imported into
Exclude from import and completion: This is actually your custom import, you can not pay attention to, in general, you do not use the
maven Configuration

To configure Maven under File->settings->build,execution,deployment->build Tools->maven, the personal configuration is shown in the following illustration

User settings file: Specifies the settings.xml location of Maven
Local repository: Specifies the location of Maven's native warehouse, which is read settings.xml automatically configured
maven home Directory: Specify the local MAVEN installation directory, because I have configured the Maven_home system parameters, so it is possible to configure IntelliJ idea directly, but if you don't have a configuration, you can choose your Maven installation directory.

VM Options for Importer: You can set the imported VM parameters, generally this does not need to actively change, unless the project is really imported too slow we increase this parameter
import Maven projects automatically: Indicates that IntelliJ idea will monitor the project's Pom.xml files for project change settings in real time, and recommend that
you check sources and documentation: Do you automatically download source code and documents when Maven imports dependency packs? The default is not checked, and do not recommend the check, because this can speed up the project from the external network to import the speed of the package, if we need the source code and documentation when we then for a dependent packet to download the network, IntelliJ idea support directly from the public network download source code and documents
maven polymerization Project built

1. Create parent project (no need to use template)



Delete the SRC directory of the parent project after the parent project is created, which is useless in the aggregation project

2. Add non-Web child modules


3. Add a Web child module (using the MAVEN Web project template)



4. After the creation of the View engineering directory structure is as follows

5. Open Pom.xml file to observe changes in Pom.xml files
Generate Serialversionuid

By default IntelliJ idea closes the warning of the class generation Serialversionuid that inherits Java.io.Serializable, and if you need to be prompted to generate SERIALVERSIONUID, you need to do the following: in file- >settings->editor->inspections Check the Java->serialization issues->serializable class without ' Serialversionuid ', put the cursor on the class name by pressing the Atl+enter key will prompt the generation of Serialversionuid
code hints Ignore case

Set case sensitive completion to none under File->settings->editor->general->code completion
Idea out of version control

Now version control has a corresponding outstanding free open source client, and the stability is better. More often than not, we want idea to be used as a development tool instead of versioning, and setting the VCs to none under File->settings->version control is out of idea versioning, configured as follows
Useful Plug-ins Recommended shortcut key Prompt plugin

Key Promoter is a shortcut key for you when you use a feature through a non-shortcut key suggestion to install a translation plugin strongly recommended when you start to remember a shortcut key

Translation plug-in Translationplugin, support to support Chinese-English translation, Word reading, detailed installation documentation please refer to: Translationplugin Introduction and Installation manual Hot deployment Plug-in Jrebel

Jrebel Hot Deployment Plug-in installation and use refer to: Jrebel Hot Deployment Plugin Install and use Maven Helper

The Maven helper plug-in is used to find a very useful plug-in installation step for MAVEN dependencies: Maven helper installation using Properties to YAML Converter

When developing springboot projects, you will need to change the configuration format of properties to YAML format, properties to YAML Converter provides a good support for Alibaba Code specification Plug-ins P3C-PMD

Detailed installation and use please refer to: Alibaba Code specification plug-in P3C-PMD Development Essentials shortcut keys

IntelliJ Idea provides a wealth of shortcut key combinations to speed up development efficiency, but too many of the shortcuts will give people a sense of the impossible. Below is my personal collation in the development process necessary shortcuts, (note: Idea shortcuts may conflict with other software shortcuts, in the development process is necessary to choose) in addition IntelliJ idea official provided a learning Idea shortcut key plug-ins: IDE Features Trainer:https://plugins.jetbrains.com/plugin/8554?pr=idea, you can go to the plugin library download learn Ctrl-related

shortcut Keys introduce
Ctrl + B Enter the interface or definition of the method/variable where the cursor is located, equivalent to CTRL + Left-click
Ctrl + D Copy the cursor's row or copy the selection and insert the copy underneath the cursor position
Ctrl + F To find text in the current file
Ctrl + H To view the inheritance structure of a class
Ctrl + N locating files by class name
Ctrl + O Quickly rewrite the parent class method
Ctrl + P Method parameter Hints
Ctrl + Y Delete the row where the cursor is located or delete the selected row
Ctrl + W Progressive selection of code blocks
Ctrl + Z Revoke
Ctrl + 1,2,3 ... 9 Navigate to the corresponding value of the bookmark position with CTRL + Shift + 1,2,3 ... 9 Use
Ctrl + F1 Displays an error message at the error code where the cursor is located
Ctrl + F12 pops up the current file structure layer and can be filtered directly on the pop-up layer
Ctrl + Space The underlying code completion defaults to be consumed by the input method on the Windows system and needs to be modified to be modified to CTRL + Comma
Ctrl +/ Note The line code that contains the cursor, using different annotation symbols depending on the current file type
ALT Related
shortcut Keys introduce
Alt + Q pops up a prompt showing the current class's declaration/context Information
Alt + Enter Provide quick fix selection based on the cursor location problem
Shift-related
shortcut Keys introduce
Shift + F3 In lookup mode, navigate to the previous match
Ctrl+alt Related
shortcut Keys introduce
Ctrl + Alt + B Used on the method name of a call to jump to a specific implementation
Ctrl + Alt + L The formatting code can use the current file and the entire package directory
Ctrl + Alt + M Quick Extraction Method
Ctrl + Alt + O Optimizing imported classes and packages can be used with the current file and the entire package directory
Ctrl + Alt + T Pop wrap option pop-up layer for selected code
Ctrl + Alt + V Fast introduction of variables
Ctrl + Alt + F7 Find the place where the class or variable is called and display it in a pop-up box
CTRL + ALT + LEFT ARROW key Back to the previous operation
CTRL + ALT + RIGHT Arrow Move forward to the previous action place
Ctrl+shift Related
shortcut Keys introduce
Ctrl + Shift + F Find whole items or files within a directory based on input
Ctrl + Shift + H To view the inheritance structure of a method
Ctrl + Shift + J Automatically merges the next line to the end of the current line
Ctrl + Shift + N Open the File/directory by file name, open the directory and add a forward slash behind the input content
Ctrl + Shift + R Replaces the content with the input, ranging from the entire project or the file in the specified directory
Ctrl + Shift + U Convert the selected code to a large/lowercase rotation
Ctrl + Shift + W Progressive deselect block of code
Ctrl + Shift + Z Cancel Undo
Ctrl + Shift +/ Code block comments
Ctrl + Shift + + Expand All Code
Ctrl + Shift +- Collapse All code
Ctrl + Shift + 1,2,3 ... 9 Quickly add a bookmark of a specified value
Ctrl + Shift + F7 Highlight all the selected text, press ESC to highlight and disappear
Ctrl + Shift + space Smart Code Hints
Ctrl + Shift + Enter Automatically end code, add semicolon at end of line
Alt+shift Related
shortcut Keys introduce
Ctrl+alt+shift Related
shortcut Keys introduce
other
shortcut
F2 jump to next highlight error or warning location
F3 in lookup mode, navigate to the next match
F4 Edit source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.