IntelliJ IDEA 2019 graphic tutorials from entry to the madness!

Read this article takes about 6 minutes.

Author: yizhiwazi

Source: www.jianshu.com/p/9c65b7613c30

Preface: IntelliJ IDEA

If IntelliJ IDEA is a modern intelligent development tools, then, Eclipse is called the Stone Age things.

In fact, the author is also an explorer Eclipse from IDEA's turn, with the recent practice of continuous development and debugging, and gradually realize the great development of the convenience brought by this smart IDE, a powerful plug-in support functions, such as for Git and Maven support people simply can not stop, a variety of code hints, including JS is Shoudaoqinlai, eventually had to be impressed by this amazing IDE. In order to close more small partners involved, I decided to write this article.

1. Comparative IDEA VS Eclipse core term

Seen from the following figure: the two biggest change is that changes in work space concept, and in which IDEA, Project and Module as two different concepts, the structure of the project is of great significance, and this is precisely what many early IDEA scholars feel troubled place.

1.1 Why you want to cancel work space?

A: Simply put, IDEA does not need to set up work space, because each will have a Project workspace! ! For each of the IDEA project (Project), each of its sub-modules (Module) can be used independent of the JDK and MAVEN configuration. This traditional reconstruction projects towards new projects added great convenience, the absence of such a wide range of adaptability is the Eclipse, because Eclipse began during the initial use has been tied to a dead workspace.

1.2 In addition, many novice will ask why IDEA inside the sub-projects will be called Module?

A: The fact is that the concept of modularity, as a polymerization engineering Yihuo common root directory, it calls Project, and the following sub-project called modules, can be associated, also no association between each sub-module.

2. Current project configuration VS default configuration

2.1 Why have a current project configuration, you need the default configuration?

A: Because IDEA is no concept of workspace, so each new project (Project) needs to set up their own MAVEN JDK and other related configuration, although this increases flexibility, but have to be reconfigured for each new project, this is clearly not in line with our expectations. In this context, the default configuration given the current project configuration provides the Default option, problems will be solved.

Supplementary: IDEA order to clarify the concept of the new project configuration, after the official version 2018.2 has been officially "Default Settings" Change the name "Default Settings / ProjectStructs", or "default configuration" means "new project configuration."

2.2 initialization step

Open the default configuration: the top navigation bar -> File -> Other Settings -> Default Settings / ProjectStructs

Open the current configuration: the top navigation bar -> File -> Settings / ProjectStructs

sample graph:

If you want to override the default configuration of the current project, directly to the Settins / Project Structure.

Next, take a look at IDEA how to quickly build Java development environment! !

3. Global JDK (default configuration)

Specific steps: the top toolbar File -> Other Settins -> Default Project Structure -> SDKs -> JDK

Example: The following figure is provided JDK directory step, and click OK to save.

Note: SDKs stands for Software Development Kit, JDK because IDEA supports a variety of development kits.

Similarly, the current project can set the JDK version love for each module in the project and Project Structure.

4. Global Maven (the default configuration)

Specific steps: the top toolbar File -> Other Settings -> Default Settings -> Build & Tools -> Maven

示例:理论上只要配置了Maven主目录即可,实际开发推荐采用User Settins file。

这里提醒一下,Apache Maven 本地仓库的地址是自动生成的,通常在C盘的用户目录里,所以在实际开发中推荐大家指定本地仓库的地址,避免因重装系统或被第三方安全工具清理而丢失数据。Maven的配置很简单,删掉注释后一目了然。(注:Maven不熟悉的,可以在我们Java知音公众号回复"maven视频",获取maven视频教程)如图:

settings.xml

打开Maven神器

还在Eclipse使用Update命令苦苦挣扎的童鞋,请火速尝试IDEA提供的Maven插件,其操作的便利性将给你带来前所未有的愉快感!!

具体步骤:右侧工具栏 Maven -> 点击展开某工程或模块 ->快速执行Maven命令。

5. 版本控制Git/Svn (默认配置)

具体步骤:顶部工具栏 File ->Other Settings -> Default Settings -> Version Control -> Git

使用说明:IDEA默认集成了对Git/Svn的支持 直接设置执行程序,右边Test提示成功即可。

问题反馈:有部分小伙伴反馈说IDEA无法找到svn.exe,解决方法:重装SVN,配置项重新选择command line client tools 即可。

PS: IDEA内置的Git插件灰常好用,尤其是解决冲突性的代码。另外Git客户端推荐SourceTree。

6. 自动导包和智能移除 (默认配置)

具体步骤:顶部工具栏 File ->Other Settings -> Default Settings -> Auto Import

使用说明:在网上看到很多人在提问IDEA为什么不能优化导包而Eclipse可以,这不是低端黑嘛, 所以特意抽出来跟大家分享IDEA如何优化导包。

7. Tomcat Server(当前项目配置)

很多小伙伴刚开始都找不到Tomcat的配置,其实很简单,Tomcat或者Jetty这些都是部署的容器,自然会联想到Deployment ,打开部署配置,可以看到应用服务器的配置。

配置Tomcat方法:File -> Settings -> Deployment -> Application Servers -> Tomcat Server

具体配置方法,如下图:

 

 

IDEA 必备小技能

为了提升开发效率,撸主贴心为大家准备以下实用指数五颗星的小技巧:

8. 自动编译

具体步骤:顶部工具栏 File ->Other Settings -> Default Settings -> Auto Import

说明:开启自动编译之后,结合Ctrl+Shift+F9 会有热更新效果。

自动编译(Runtime)

具体步骤:敲击 Ctrl + Shift + Alt + / 然后双击Shift搜索进入Registry ,找到compiler.automake.allow.when.app.running ,然后勾选上。

9. 取消大小写敏感

具体步骤:

File | Settings | Editor | General | Code Completion Case | Sensitive Completion = None

取消大小敏感,在编写代码的时候,代码的自动提示将更加全面和丰富。

10. 调整字体类型和字体大小

默认的白色背景和细小的字体会影响大家的编码体验,这里特意提供了调整代码窗的快捷配置。打开配置,搜索Font,然后再Font可以调整字体类型,Size可以调整字体大小,如图:

11. 将快捷键设置为跟Eclipse一样

很多人可能并不习惯IDEA的快捷键,为了方便,这里我们将快捷键设置为跟 Eclipse一样。

具体步骤: File -> Settings -> Keymap - > 选择Eclipse .

从Eclipse转过来的小伙伴 可以放心使用

12. 打开常用工具栏

具体步骤:顶部导航栏 - View -> 勾选 Toolbar & Tool Buttons

如下图所示:

13. 懒人必备快捷键

A. 按【鼠标中键】快速打开智能提示,取代alt+enter 。

File->Settings-> Keymap-> 搜索 Show Intention Actions -> 添加快捷键为鼠标中键。

B. 按【F2】快速修改文件名,告别双手操作。

File->Settings-> Keymap-> 搜索 Rename -> 将快捷键设置为F2 。

C. 按【F3】直接打开文件所在目录,浏览一步到位。

File->Settings-> Keymap-> 搜索 Show In Explorer -> 将快捷键设置为F3 。

D. 按【Ctrl+鼠标右键】直接打开实现类,方便开发查询。

File->Settings-> Keymap-> 搜索 implementation-> Add Mouse Shortcut 将快捷键设置为Ctrl+ 鼠标右键。

14. 重度强迫症患者

A.取消大小写敏感,让自动提示更齐全!

File | Settings | Editor | General | Code Completion Case | Sensitive Completion = None。

B.隐藏开发工具的配置目录 例如

.idea;

.iml

 

File | Settings | File Types | 在末尾加上

.idea;

.iml

 

C.收起注释,让源码阅读更为清爽!

File -> Settings -> Editor -> General -> Code Folding -> Documentation comments 勾选。

如何想快速一键打开全部注释,则单击鼠标右键,选择Folding -> Expand Doc comments 。

15. IDEA问答

(1).如何打开本地工程/已存在的工程?

答:点击File -> Open 打开 工程文件夹即可,注意先配置好JDK、Maven等基础配置。

(2).IDEA如何删除项目工程?

答:问这个问题的Coder真的好可爱啊哈哈,很肯定的回答你,不需要删,

点击File-> Close Project 即可快速关闭当前项目;

示例:

什么?你还是想要干掉整个目录?那也阔以,右键Show In Explorer ,删掉文件夹 即可。不过笔者建议还是直接Close关掉就好啦,万一以后用得上呢,你说呢?

(3).如何在单个窗口打开多个Maven工程啊?

答:随便新建一个文件夹,然后将工程都扔进去,使用IDEA打开这个文件夹。

(4).如何为当前项目工程添加多个模块啊?

答:对着工程右键 -> 选择New -> Module -> 通常选择Spring Initializr ,如图:

新增模块

多模块工程

 

 

End

之前发了一篇【美团】Java 岗 154 道面试题 的文章,只有面试题没有解析,接下来准备在下方公众号内发布解析(工作日:面试题解析+IT 趣图,周末:IT 趣图),利用碎片时间看面试题解析,持续精进,赶紧关注一波。

 

·END·

程序员的成长之路

路虽远,行则必至

本文原发于 同名微信公众号「程序员的成长之路」,回复「1024」你懂得,给个赞呗。

回复 [ 520 ] 领取程序员最佳学习方式

回复 [ 256 ] 查看 Java 程序员成长规划

 

Guess you like

Origin www.cnblogs.com/gdjk/p/11263617.html