IntelliJ IDEAbasicconcepts

MasterIntelliJ IDEA core concepts, including界面组成, projectstructure, module and 依赖etc.

1. IntelliJ IDEA界面组成

IntelliJ IDEA 界面由 many 个主要部group成, 每个部分都 has 其specific functions. Understand这些界面元素 作用 and usingmethod, has 助于improving你 Developmentefficiency.

1.1 主菜单栏

主菜单栏位于界面顶部, package含了IntelliJ IDEA 所 has functions菜单, such asFile, Edit, View, Navigate, Code, Refactor, build, Run, Tools, VCS, Window and Helpetc..

1.2 tool栏

tool栏位于主菜单栏 under 方, providing了常用functions fast 捷按钮, such as new 建project, 打开file, 保存, run, debug, version控制etc.operation. 你可以根据需要自定义tool栏 in 容.

1.3 导航栏

导航栏位于tool栏 under 方, 显示当 before project structure, 方便你 in project 不同部分之间 fast 速导航.

1.4 projecttool窗口

projecttool窗口通常位于界面 left 侧, 显示当 before project filestructure, includingsourcescode, resourcefile, 依赖libraryetc.. 你可以through点击不同 tag页切换 to othertool窗口, such asStructure, Favorites, Scratchesetc..

1.5 编辑器窗口

编辑器窗口 is IntelliJ IDEA core部分, 位于界面in央, 用于writing and 编辑code. 编辑器support语法highlight, code补全, error提示etc.functions.

1.6 status栏

status栏位于界面底部, 显示当 before project statusinformation, such as当 before branch, file编码, 行号, 列号, 语法checkstatusetc..

1.7 othertool窗口

IntelliJ IDEA还providing了许 many othertool窗口, such asTerminal, Database, Debug, Run, TODOetc., 这些tool窗口可以根据需要显示 or 隐藏, 通常位于界面底部 or right 侧.

2. IntelliJ IDEAprojectstructure

in IntelliJ IDEAin, project is Development工作 basic单位. Understandprojectstructure concepts and 组成部分, has 助于你更 good 地组织 and management你 code.

2.1 project (Project)

project is IntelliJ IDEAin最advanced别 组织单位, 代表一个完整 Developmenttask. 一个project可以package含 many 个module, 每个module负责specific functions.

2.2 module (Module)

module is project 组成部分, 代表projectin 一个functions单元. 一个module可以package含自己 sourcescode, resourcefile, 依赖libraryetc.. module之间可以相互依赖, 形成 complex projectstructure.

2.3 sources根 (Source Root)

sources根 is 指package含sourcescode Table of Contents, IntelliJ IDEA会将sources根in file视 for 可编译 sourcescode. in Javaprojectin, sources根通常 is src/main/javaTable of Contents.

2.4 testsources根 (Test Source Root)

testsources根 is 指package含testcode Table of Contents, IntelliJ IDEA会将testsources根in file视 for testcode. in Javaprojectin, testsources根通常 is src/test/javaTable of Contents.

2.5 resource根 (Resource Root)

resource根 is 指package含resourcefile Table of Contents, such asconfigurationfile, graph片, 音频etc.. in Javaprojectin, resource根通常 is src/main/resourcesTable of Contents.

2.6 testresource根 (Test Resource Root)

testresource根 is 指package含testresourcefile Table of Contents. in Javaprojectin, testresource根通常 is src/test/resourcesTable of Contents.

3. IntelliJ IDEAmodule and 依赖

in IntelliJ IDEAin, module is project basic组成单位, 而依赖则 is module之间 or module and out 部library之间 relationships. Understandmodule and 依赖 concepts and managementmethod, has 助于你更 good 地组织 and management complex project.

3.1 module依赖

module依赖 is 指一个module依赖于另一个module circumstances. 当一个module依赖于另一个module时, 它可以访问被依赖modulein class and resource.

3.2 out 部library依赖

out 部library依赖 is 指module依赖于 out 部第三方library circumstances. IntelliJ IDEAsupport many 种依赖management方式, such asMaven, Gradle, Ivyetc..

3.3 依赖范围

依赖范围定义了依赖 in project构建过程in 可见性 and availability. common 依赖范围including:

  • Compile: 默认范围, 依赖 in 编译, test and run时都可用.
  • Test: 依赖仅 in test时可用, 编译 and run时不可用.
  • Provided: 依赖 in 编译 and test时可用, run时由containers or environmentproviding.
  • Runtime: 依赖 in test and run时可用, 编译时不可用.
  • System: 依赖 in 编译, test and run时都可用, 但需要显式指定path.

3.4 依赖conflict

当projectin存 in many 个version 同一依赖时, 就会发生依赖conflict. IntelliJ IDEAproviding了依赖analysistool, 可以helping你识别 and 解决依赖conflict.

4. IntelliJ IDEAprojectconfiguration

IntelliJ IDEAproviding了丰富 projectconfiguration选项, 允许你根据自己 requirements自定义project behavior and out 观.

4.1 project设置

project设置package含了project级别 configuration, such asSDKconfiguration, projectlanguage级别, project编码, moduleconfiguration, 依赖configurationetc.. 你可以through点击File > Project Structure打开project设置 for 话框.

4.2 IDE设置

IDE设置package含了IntelliJ IDEA 全局configuration, such as编辑器设置, out 观设置, fast 捷键设置, 插件configurationetc.. 你可以through点击File > Settings (Windows/Linux) or IntelliJ IDEA > Preferences (macOS) 打开IDE设置 for 话框.

4.3 run/debugconfiguration

run/debugconfiguration定义了such as何run and debugproject. 你可以through点击Run > Edit Configurations打开run/debugconfiguration for 话框, creation and management各种run/debugconfiguration.

4.4 code风格configuration

code风格configuration定义了code format规则, such asindent, 换行, 空格etc.. IntelliJ IDEA in 置了 many 种code风格模板, 你也可以根据自己 requirements自定义code风格.

实践练习

请按照以 under 步骤completion练习:

  1. 启动IntelliJ IDEA, 打开一个project.
  2. 熟悉IntelliJ IDEA 界面组成, 尝试using不同 tool窗口.
  3. 查看project structure, 识别sources根, testsources根 and resource根.
  4. 尝试configurationproject SDK and language级别.
  5. 自定义IntelliJ IDEA out 观 and 主题.
  6. creation一个 simple run/debugconfiguration, 并runproject.