My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


# 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, we decided to write this article and share it with the king.

# IntelliJ IDEA Tutorial

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.

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


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?

答:因为IDEA没有工作空间的概念,所以每个新项目(Project)都需要设置自己的JDK和MAVEN等相关配置,这样虽然提高了灵活性,但是却要为每个新项目都要重新配置,这显然不符合我们的预期。在这个背景下,默认配置给予当前项目配置提供了Default选项,问题自然就迎刃而解了。

最新补充:IDEA为了明确这个新项目配置的概念,在2018.2之后的正式版本已正式将“Default Settings”名字修改“ Default Settings /ProjectStructs”,即“默认配置”就是指“新项目配置”。

2.2 初始化步骤


打开默认配置:顶部导航栏 -> File -> Other Settings -> Default Settings /ProjectStructs

打开当前配置:顶部导航栏 -> File -> Settings / ProjectStructs

示例图:

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


如果当前项目想覆盖默认配置,直接在Settins/Project Structure设置即可

接下来,来看看IDEA如何快速搭建Java开发环境!!


3. 全局JDK(默认配置)

具体步骤:顶部工具栏 File ->Other Settins -> Default Project Structure -> SDKs -> JDK

示例:根据下图步骤设置JDK目录,最后点击OK保存。

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


注:SDKs全称是Software Development Kit ,因为IDEA支持JDK等多种开发工具包。


同理,当前项目在Project Structure可为工程和各模块设置喜欢的JDK版本。

4. 全局Maven(默认配置)


具体步骤:顶部工具栏 File ->Other Settings -> Default Settings -> Build & Tools -> Maven

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


My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)



这里提醒一下,Apache Maven 本地仓库的地址是自动生成的,通常在C盘的用户目录里,所以在实际开发中推荐大家指定本地仓库的地址,避免因重装系统或被第三方安全工具清理而丢失数据。Maven的配置很简单,删掉注释后一目了然。如图:

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


settings.xml

# 打开Maven神器


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

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


My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


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


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

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

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

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


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

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


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

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

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


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

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

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

具体配置方法,如下图:

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)



# IDEA 必备小技能


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

8. 自动编译


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

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

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


# 自动编译(Runtime)


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

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


9. 取消大小写敏感


具体步骤:

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

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

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


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


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

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


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


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

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


My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)



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

12. 打开常用工具栏

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

如下图所示:

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)



13. 懒人必备快捷键

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

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

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

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

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

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

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

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

14. 重度强迫症患者

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

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

2.隐藏开发工具的配置目录 例如 *.idea;*.iml

File | Settings | File Types | 在末尾加上 *.idea;*.iml

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

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

How quickly would like a key to open all comments, click the right mouse button, select Folding -> Expand Doc comments.


15. IDEA Ten Questions ten A


(1) How to open a local project / existing project?


A: Click on File -> Open to open the project folder can pay attention to configure the JDK, Maven and other basic configurations.

How (2) IDEA delete the project?


A: ask this question Coder really cute ah ha ha, very sure of your answer, do not need to delete,

Click File-> Close Project to quickly close the current project; example:

what? You still want to get rid of an entire directory? It is also to wide, right-Show In Explorer, delete the folder. But I still recommend direct Close to turn off the thousand million, in case after the lingua franca of it, you say?

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


(3) How to open multiple windows in a single Maven project ah?


A: just create a new folder, and then are thrown to the project, using IDEA open this folder.

(4) How is the current project to add more modules ah?


A: Right in front of the project -> select New -> Module -> usually choose Spring Initializr,

Figure:

My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)


My collection of IntelliJ IDEA Tutorial (2019 facsimile edition)



Guess you like

Origin blog.51cto.com/14528283/2437755