博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
彻底掌握intellij_如何掌握IntelliJ来提高您的生产力
阅读量:2523 次
发布时间:2019-05-11

本文共 9427 字,大约阅读时间需要 31 分钟。

彻底掌握intellij

DISCLAMER: This isn’t some free advertising for JetBrains, this is only about a developer sharing tips about IntelliJ.

免责声明:这不是JetBrains的一些免费广告,这只是关于开发人员共享有关IntelliJ的提示的。

Without a doubt, the most important developer tool is the development environment (called ).

毫无疑问,最重要的开发人员工具是开发环境(称为 )。

My favourite and the one I work with every day at work is IntelliJ (Ultimate version). In this article, I’ll share with you all the tips and tricks I’ve gathered from my experience and from my colleagues. This might help you master this tool and make your work easier.

我最喜欢的是我每天工作的人,是IntelliJ (最终版本)。 在本文中,我将与您分享我从我的经验以及我的同事那里收集的所有提示和技巧。 这可能会帮助您精通此工具,并使您的工作更轻松。

Don’t leave if you don’t use IntelliJ or even if you hate it! I bet you can apply many of these tricks to your favourite IDE.

如果您不使用IntelliJ甚至讨厌它,也不要离开! 我敢打赌,您可以将许多技巧应用于您喜欢的IDE。

目录 (Table of Contents)

  • Last piece of advice: , , , ,

    最后一条建议: , , , ,

将微服务转换为模块 (Convert microservices into modules)

If you work on many projects or your project implements a microservice architecture, you have independent projects in many directories.

如果您从事许多项目,或者您的项目实现了微服务架构,则在许多目录中都有独立的项目。

This means you have to create one IntelliJ project for each project directory. Yet, you can’t have more than one project in a single IntelliJ window.

这意味着您必须为每个项目目录创建一个IntelliJ项目。 但是,在一个IntelliJ窗口中不能有多个项目。

Creating modules is the solution. The idea is to create one IntelliJ project with independent modules.

解决方案就是创建模块。 这个想法是创建一个具有独立模块的IntelliJ项目。

You can manage all modules in the Project Structure window (File > Project Structure). They’re also accessible by right-clicking on a single module and choosing Open Module Settings.

您可以在“项目结构”窗口( File > Project Struct )中管理所有模块。 也可以通过右键单击单个模块并选择“ ng Open Module Setti访问它们。

进行有效的代码审查 (Have effective code reviews)

I hope you’re using a version control system such as Git or Subversion. If you aren’t, you should consider learning more about version control systems!

希望您使用的是版本控制系统,例如Git或Subversion。 如果不是,则应考虑学习有关版本控制系统的更多信息!

IntelliJ provides a good integration for VCS, especially for code reviews. If your project contains many repositories within your modules, it’s possible to visualize every commit in one place.

IntelliJ为VCS提供了很好的集成,尤其是对于代码审查。 如果您的项目在模块中包含许多存储库,则可以在一处可视化每个提交。

First, check if version control knows your directories:

首先,检查版本控制是否知道您的目录:

Then, go check this tool window:

然后,检查此工具窗口:

You only have to enable the Show Root Names option to see the modules’ names on the left. The Paths filter allows you to filter using module names. Useful when you work on projects with a microservice architecture!

您只需启用“ Show Root Names选项即可在左侧查看模块的名称。 使用路径过滤器可以使用模块名称进行过滤。 当您在具有微服务架构的项目上工作时很有用!

The right side of this window shows every modified file from the selected commit. You can click on Show Diff to open a new window and visualize modifications for each file.

该窗口的右侧显示了所选提交中的每个修改后的文件。 您可以单击“ Show Diff打开一个新窗口,并可视化每个文件的修改。

If you need to review multiple commits at the same time, select the commits to review (hold the ctrl key) and click on Show Diff.

如果您需要同时查看多个提交,请选择要查看的提交(按住ctrl键),然后单击Show Diff

还原多个提交 (Revert multiple commits)

For some reason, you may need to revert a few commits in your project. If you’re not used to doing it, you can get into trouble.

由于某些原因,您可能需要在项目中还原一些提交。 如果您不习惯这样做,可能会遇到麻烦。

Revert a commit is quite simple: right-click on it and choose revert. Once you eventually fix the conflicts, a commit popup will come up. If you only revert one commit, do as usual without checking the Amend commit option.

还原提交非常简单:右键单击它,然后选择还原。 一旦您最终解决了冲突,就会弹出一个提交弹出窗口。 如果仅还原一次提交,请照常进行,而无需选中“ Amend commit选项。

But if you need to revert multiple commits, you have to be a bit more clever. The idea is to create one commit which reverts all commits at once — begin with the most recent to avoid conflicts.

但是,如果您需要还原多个提交,则必须更加聪明。 这个想法是创造一个 commit一次还原所有提交-从最近一次开始以避免冲突。

When you revert a commit, you must commit the changes. It means you can’t perform multiple reverts and finally commit the result. My solution is to commit the first revert and then check the Amend commit option to squash the other reverts into this first commit.

还原提交时,必须提交更改。 这意味着您不能执行多次还原并最终提交结果。 我的解决方案是提交第一次还原,然后检查“ 修改提交”选项以将其他还原压入此第一次提交。

Java开发人员的安全检查 (Safety checks for Java devs)

IntelliJ comes with a lot of features for Java, including Maven integration. It’s highly configurable, but before exploring, you need to check some settings.

IntelliJ具有许多Java功能,包括Maven集成。 它是高度可配置的,但是在探索之前,您需要检查一些设置。

  • Project SDK (File > Project Structure)

    Project SDK (文件> Project结构 )

  • Java compiler version for each module (File > Settings > Java Compiler)

    每个模块的Java编译器版本(“文件”>“设置”>“ Java Com堆积器”)

  • Maven configuration (File > Settings > Maven)

    Maven配置(“文件”>“设置”>“ Maven”)

For Maven configuration, consider checking Always update snapshots if you work on microservice architectured projects.

对于Maven配置,如果您在微服务架构项目上工作,请考虑选中Always update snapshots

Don’t forget to also check the Ignored Files section to make sure IntelliJ doesn’t ignore your module pom.xml. If your module is still not recognized as a Maven project, right click on your pom.xml and Add as Maven Project.

不要忘记也检查“被忽略的文件”部分,以确保IntelliJ不会忽略您的模块pom.xml 。 如果您的模块仍未被识别为Maven项目,请右键单击pom.xmlAdd as Maven Project

Sometimes you can compile using the terminal, but IntelliJ finds errors because of the Maven dependencies. To fix that, right click on the module Maven > Reload and then right click again to Rebuild the module.

有时您可以使用终端进行编译,但是由于Maven依赖性,IntelliJ会发现错误。 要解决此问题,请右键单击模块Maven > Rel to Rebu ,然后再次右键单击以重新to Rebu模块。

与您的数据库讨论 (Discuss with your database)

I tried some clients to deal with databases, but using IntelliJ is far better when you’re also writing code.

我尝试了一些客户端来处理数据库,但是当您还要编写代码时,使用IntelliJ会更好。

You can explore your database without writing any code using the tree explorer. Then, if you double-click on a table, you can also filter results, perform some CRUD operations, and even export the data in many formats such as SQL, CSV and HTML.

您可以使用树浏览器浏览数据库而无需编写任何代码。 然后,如果双击表,则还可以过滤结果,执行某些CRUD操作,甚至以多种格式导出数据,例如SQL,CSV和HTML。

As you might think, SQL files support , autocomplete and the ability to run queries from the file. The good part is that you can write multiple queries in your file but only run highlighted queries with Ctrl + Enter.

您可能会想到,SQL文件支持 ,自动完成以及从文件运行查询的功能。 好消息是您可以在文件中编写多个查询,但只能使用Ctrl + Enter运行突出显示的查询。

最后的建议 (Last pieces of advice)

运行仪表板 (Run dashboard)

It’s possible to run your applications from IntelliJ, but you need to create a Run Configuration first. Once some process is running you’ll be able to list them all on a dashboard.

可以从IntelliJ运行您的应用程序,但是您需要首先创建一个Run Configuration 。 一旦运行了某个流程,您就可以在仪表板上列出所有流程。

To enable the Run Dashboard, open the Run Configuration popup and select Defaults. Then, you can add which kind of configuration can appear in your run dashboard.

要启用“运行仪表板”,请打开“运行配置”弹出窗口,然后选择“ Defaults 。 然后,您可以添加哪种配置可以显示在运行仪表盘中。

标记目录 (Marked directories)

When you do a right-click on a directory, you have the option to mark it as Source, Test, and even exclude it.

在目录上单击鼠标右键时,可以选择将其标记为“源”,“测试”,甚至将其排除。

It’s useful, because you can hide excluded files in your project and also filter search results so that they don’t display tests (in scope > Production Files).

这很有用,因为您可以在项目中隐藏排除的文件,还可以过滤搜索结果,以使它们不显示测试(在范围>生产文件中 )。

暂存文件 (Scratch files)

Creating temporary files is very convenient to test something outside of your project. IntelliJ supports this feature (shortcut: Ctrl + Alt +Maj + Insert) with many kinds of files such as JavaScript and SQL. Plugins can help you to run those files. I recommend you to try Quokka which runs JS scratch files.

创建临时文件对于测试项目外部的内容非常方便。 IntelliJ通过许多文件(例如JavaScript和SQL )支持此功能(快捷键:Ctrl + Alt + Maj + Insert) 插件可以帮助您运行这些文件。 我建议您尝试运行JS暂存文件的Quokka。

安装插件 (Install plugins)

Plenty of plugins exist for IntelliJ — almost every popular framework and language has one. You should install those plugins and check if they help you in your daily work.

IntelliJ有很多插件-几乎每种流行的框架和语言都有一个。 您应该安装这些插件,并检查它们是否对您的日常工作有所帮助。

For instance, check which might be interesting for Java developers. You can also set up a particular font to easily distinguish similar characters such as l 1 I and O 0 o. I’d recommend and which help avoid confusing similar characters.

例如,选中“ ,这可能对Java开发人员很有趣。 您还可以设置特定的字体以轻松区分类似的字符,例如l 1 IO 0 o 。 我建议使用和 ,这有助于避免混淆相似的字符。

过度使用快捷键 (Overuse shortcuts)

  • shift + shift searches everywhere for a file

    shift + shift随处搜索文件

  • ctrl + shift + E for recently opened files

    ctrl + shift + E用于最近打开的文件)

  • ctrl + shift + F searches a text in the path (use the module filter)

    ctrl + shift + F在路径中搜索文本(使用模块过滤器)

  • ctrl + click jumps to variable/function declaration

    ctrl + click跳转到变量/函数声明

  • ctrl + f12 searches variable/function in file

    ctrl + f12在文件中搜索变量/函数

  • alt + F7 lists variable/function usages

    alt + F7列出变量/函数的用法

Thanks for reading! This was a compilation of tips and tricks I’ve learned with experience and also with help from my colleagues. I hope you found something helpful for your daily work with IntelliJ!

谢谢阅读! 这是我从经验中学到的技巧和窍门的汇总,也得到了同事的帮助。 希望您发现对IntelliJ的日常工作有所帮助!

If you found this article useful, please click on the ? button a few times to make others find the article and to show your support! ?

如果您发现本文有用,请单击“ ?”。 几次单击以使其他人找到该文章并表示您的支持!

Don’t forget to follow me to get notified of my upcoming articles ?

别忘了跟随我以获取有关我即将发表的文章的通知吗?

➥JavaScript (➥ JavaScript)

➥提示与技巧 (➥ Tips & tricks)

翻译自:

彻底掌握intellij

转载地址:http://lfkzd.baihongyu.com/

你可能感兴趣的文章
9.25
查看>>
javascript函数
查看>>
java泛型中<?>和<T>有什么区别?
查看>>
Vue.js——60分钟组件快速入门
查看>>
logback配置方式
查看>>
laravel 数据库操作小例子
查看>>
javascript中对象属性的介绍
查看>>
3天CSS总结
查看>>
一周复习总结(一)第二周
查看>>
similarity 字符串编辑距离相似度匹配
查看>>
linux中什么是shell?
查看>>
谈谈MySql数据库锁
查看>>
Mac上搭建rtmp流媒体服务器(结合FFmpeg的使用)
查看>>
mybatis06--动态sql
查看>>
C# WinForm开发系列 - Controls
查看>>
Thrust快速入门教程(二)——Vector的使用
查看>>
Java的概念
查看>>
opencv图像线性混合&imread()
查看>>
C++计算毫秒
查看>>
Spring IOC(转载)
查看>>