Intellij Idea 简明教程

Intellij Idea - Getting Familiar

在本章中,我们将更熟悉 IntelliJ IDEA。要讨论任何工具的优势和功能,人们必须熟悉该工具,而 IntelliJ 也不例外。

In this chapter, we will get more familiar with IntelliJ IDEA. To discuss the advantages and functionality of any tool, one must be familiar with that tool and IntelliJ is no exception to that.

本章概述了 IntelliJ。本章从讨论 IDE 的可视元素、配置设置开始,最后以讨论 JVM 和平台属性结束。

This chapter gives you an overview of IntelliJ. The chapter begins with a discussion about IDE’s visual elements, configuration settings and finally ends by discussing JVM and platform properties.

Visual Elements

关于 IDE 的重要内容之一是其可视元素。识别和理解可视元素使您能够以一种 quicker 更简单的方式执行操作。以下屏幕截图及其上的标签显示了 IntelliJ 的主界面。

One of the important things about IDE is its visual elements. Identifying and understanding the visual elements enables to you do action in a quicker and easier manner. The following screenshot and the labels on it show the main interface of IntelliJ.

visual elements

在主窗口的底部,有一个 status 栏,其中显示了有关文件的某些其他属性,例如其格式和编码类型。它还提供了切换当前文件只读属性的选项。您还可以在此处管理检查级别。

At the bottom of the main window, there is a status bar, which shows some additional attributes about the file - like its format and the encoding type. It also provides option to toggle the read-only attribute of the current file. You can also manage inspection level from here.

Working with Plug-ins

插件有助于扩展 IntelliJ 的功能。它提供了大量插件,包括数据库、版本控制、配置文件等等。

Plug-ins help to extend functionality of IntelliJ. It provides a large number of plug-ins ranging from databases, version controlling, profiling and this list goes on.

plug ins ranging

Steps to manage plug-ins

按照以下步骤管理插件 −

Follow these steps to manage plug-ins −

  1. Go to the File → Settings menu.

  2. Select the Plugins tab on the left pane.

  3. This window lists all installed plug-ins. There is a checkbox on the right side of each plug-in name. Toggling that checkbox enables/disables the plug-ins.

  4. IntelliJ online plug-in repository is available here. To add/remove plug-in repository, click on the browse repository button and it will provide a way to do needful.

  5. In addition to this, it allows offline plug-in installation. For this, download plug-in and select install plug-in from the disk button and navigate to the download path.

要对插件执行其他操作,如卸载、更新和排序,请右键单击任意插件。它将显示一个下拉菜单,从中可以选择其中一个操作。

To perform other actions on plug-ins like uninstalling, updating and sorting, right-click on any plug-in. It will show a dropdown menu from which you can select one of the actions.

Working with Settings

本节提供了一些管理设置的重要提示。它使您可以导入、导出和共享 IntelliJ 设置。

This section provides a few important tips to manage settings. It enables you to import, export and share IntelliJ settings.

Export Settings

它允许将当前设置导出为 jar 文件。

It allows exporting the current settings as a jar file.

  1. Go to File → Export Settings.

  2. Export setting windows list the available settings related to UI, debugger, SDK along with others.

  3. It provides a checkbox for selection. Once the selection is done, click on the OK button to save the settings on the local disk.

Import Settings

它允许导入 jar 文件中存储的设置。

It allows importing the settings stored in the jar file.

  1. Go to File → Import settings.

  2. Select the Setting jar by navigating folder structure

  3. Click on the OK button.

Sharing Settings

IntelliJ IDEA 允许你在不同的实例之间共享你的 IDE 设置。当你想在团队或组织内应用相同的设置时,这特别有用。要实现此目的的前提条件是启用 Settings Repository 插件。它默认安装并启用。

IntelliJ IDEA allows you to share your IDE settings between different instances. This is particularly useful when you want to apply the same settings within a team or organization. The prerequisite for this is to enable the Settings Repository plug-in. It is installed and enabled by default.

要确保其状态 −

To ensure its status −

  1. Go to File → Settings → Plugins

  2. Search settings repository plug-in

我们可以将当前设置存储在 GitHub/Bitbucket 上,并将其应用于其他实例。要存储当前设置 −

We can store the current setting on GitHub/Bitbucket and apply them on other instances. To store the current setting −

  1. Go to the File → Settings Repository.

  2. Type the Git repository URL in upstream URL dialog box.

  3. Click on the Overwrite remote button.

  4. To apply the same settings to other instances, click on the Overwrite local button.

Configuring JVM Options and Platform Properties

可以通过导航到 Help → Edit Custom VM Options 菜单配置 JVM 选项。以下是我们可以设置的一些重要的 JVM 选项。

We can configure the JVM options by navigating to the Help → Edit Custom VM Options menu. Following are a few important JVM options we can set.

  1. –server − It allows the selection of the Java HotSpot Server VM

  2. -Xms<size> − It sets the initial Java heap size. The default value is 128 MB.

  3. -Xmx<size> − It sets the maximum Java heap size. The default value is 750 MB.

  4. -Xss<size> − It sets the Java thread stack size.

  5. –XX − It allows setting GC algorithm and other properties.