8

IntelliJ IDEA 配置

 3 years ago
source link: https://segmentfault.com/a/1190000041150597
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

IntelliJ IDEA 配置

发布于 今天 13:13

IntelliJ IDEA是一种商业化销售的Java集成开发环境(Integrated Development Environment,IDE)工具软件,由JetBrains软件公司(前称为IntelliJ)开发,提供Apache 2.0开放式授权的社区版本以及专有软件的商业版本,开发者可选择其所需来下载使用。 --wikipedia

1.1 编码

一般来说,在没有任何配置的情况下,IntelliJ IDEA 默认的编码是使用系统的编码,在有些中文语言的 Windows 版本上的编码是 GBK ,这会导致你的 IntelliJ IDEA 的编码也是 GBK,因此一开始使用该编辑器的时候可以检查下编码。

Preferences -> Editor -> File Encodings

image.png

你还可以勾选 Transparent native-to-ascii conversion 选项,将 Unicode 字符转换成指定的编码,默认使用 UTF-8 即可。这是因为 .properties 文件是 ISO-8859-1 的编码,对于无法识别的字符会翻译成 Unicode 。勾选之后效果如下:

hello=\u4F60\u597D,\u4E16\u754C
hello=hello,world
hello=你好,世界
hello=hello,world

1.2 字体与字体大小

Preferences -> Editor -> Font

推荐使用等宽风格字体,个人比较喜欢 JetBrains Mono

image.png

该字体效果预览如下:

image.png

1.3 自定义文件模版

Preferences -> Editor -> File and Code Templates

使用 IntelliJ IDEA 中创建一个类,比如 App ,创建之后的格式如下:

public class App {
    
}

有时候我们希望在类上面添加一些额外的信息,比如作者、日期等。这时候我们就可以自定义文件模版,在 Description 中描述可以引用的变量:

image.png

可以将文件同步更新在:

  • Class :类。
  • Inteface :接口。
  • Enum :枚举。
  • AnnotationAtype :注解。
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
#parse("File Header.java")
/**
 * @author <a href="mailto:[email protected]">shaw</a>
 */
public class ${NAME} {
}

设置后效果如下:

/**
 * @author <a href="mailto:[email protected]">shaw</a>
 */
public class App {
}

1.4 代码外观设置

Preferences -> Editor -> General -> Appearance

image.png
image.png

1.5 智能提示

Preferences -> Editor -> General -> Code Completion

image.png

不勾选效果:

image.png

勾选效果:

image.png

1.6 缩进

Preferences -> Editor -> Code Style -> Java

勾选使用 Tab 缩进,否则使用空格缩进。

image.png

1.7 显示文件的详细信息

View -> Appearance -> Deetails in Tree View

image.png

image.png


2. 构建/部署/执行

2.1 配置Maven

Preferences -> Build, Execution, Deployment -> Build Tools -> Maven

image.png

2.2 委托给Maven运行

image.png

Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Runner

2.3 热部署

Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler

image.png

2.4 设置项目的JDK

image.png

image.png

Preferences -> Build, Execution, Deployment -> Compiler -> Java Compiler

image.png

Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Runner

image.png


3. 导入导出配置

image.png



Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK