必备材料介绍

IntelliJ IDEA 对其他 IDE 转过来的用户有特别优待,对其专门整理了非常棒的资料,还请其他 IDE 过来的用户抽时间查看,会有很大帮助:
Eclipse 用户可以看:https://www.jetbrains.com/idea/help/eclipse.html
NetBeans 用户可以看:https://www.jetbrains.com/idea/help/netbeans.html

这两个概念是 IntelliJ IDEA 的必懂知识点之一,请务必要学会。

如果你是 Eclipse 用户,并且已经看了上面给的链接,那 IntelliJ IDEA 首先告诉你一个非常重要的事情:IntelliJ IDEA 没有类似 Eclipse 工作空间(workspace)的概念的。很多从 Eclipse 转过来的人总是下意识地要再同一个窗口管理 n 个项目,这在 IntelliJ IDEA 是无法得到。IntelliJ IDEA 提供的体验是:一个 Project 打开一个 Window 窗口。

对于 Project,IntelliJ IDEA 是这样解释的:

Whatever you do in IntelliJ IDEA, you do that in the context of a project. A project is an organizational unit that represents a complete software solution. It serves as a basis for coding assistance, bulk refactoring, coding style consistency, etc.

Your finished product may be decomposed into a series of discrete, isolated modules, but it's a project definition that brings them together and ties them into a greater whole.

Projects don't themselves contain development artifacts such as source code, build scripts, or documentation. They are the highest level of organization in the IDE, and they define project-wide settings as well as collections of what IntelliJ IDEA refers to as modules and libraries.

链接地址:https://www.jetbrains.com/idea/help/project.html

对于 Module,IntelliJ IDEA 是这样解释的:

A module is a discrete unit of functionality which you can compile, run, test and debug independently.

Modules contain everything that is required for their specific tasks: source code, build scripts, unit tests, deployment descriptors, and documentation. However, modules exist and are functional only in the context of a project.

Configuration information for a module is stored in a .iml module file. By default, such a file is located in the module's content root folder.

Development teams, normally, share the .iml module files through version control.

链接地址:https://www.jetbrains.com/idea/help/module.html

通过上面的介绍我们知道,在 IntelliJ IDEA 中 Project 是最顶级的级别,次级别是 Module。一个 Project 可以有多个 Module。目前主流的大型项目结构都是类似这种多 Module 结构,这类项目一般是这样划分的,比如:core Module、web Module、plugin Module、solr Module 等等,模块之间彼此可以相互依赖。通过这些 Module 的命名也可以看出,他们之间应该都是处于同一个项目业务情况下的模块,彼此之间是有不可分割的业务关系的。

所以我们现在总结:一个 Project 是由一个或多个 Module 组成,模块之间尽量是处在同一个项目业务的的情况下,彼此之间互相依赖关联。这里用的是 尽量,因为 IntelliJ IDEA 的 Project 是一个没有具备任何编码设置、构建等开发功能的,主要起到一个项目定义、范围约束、规范等类型的效果,也许我们可以简单地理解为就是一个单纯的目录,只是这个目录命名上必须有其代表性的意义。

下面我们以著名的 spring-framework 项目为例介绍多 Module 的结构的:

项目主页:https://github.com/spring-projects/spring-framework

该项目的 Project 命名是:spring-framework。该目录主要作用为各个 Module 的顶层目录进行约束,告诉协同者,这个目录下都是 spring-framework 相关的,我绝不会放 Android 相关源码、文档、文件在上面的。该目录并不是以一个实际性的目录来体现的,所以你访问主页是看不到的,但是当你 checkout 的时候,你必须为这个项目命名,至于命名默认就是 spring-framework

Project 下有二十来个 Module,各个 Module 的命名也是有含义的,比如:spring-corespring-jdbcspring-jmsspring-ormspring-webspring-webmvc 等等,我们通过这些命名也能清楚地知道他们要表达的含义,这些 Module 下也都各自有 src 编码目录,可以自行编码和构建。

相比较于多 Module 项目,小项目就无需搞得这么复杂。只有一个 Module 的结构 IntelliJ IDEA 也是支持的,并且 IntelliJ IDEA 创建项目的时候,默认就是单 Module 的结构的。

如上图 Gif 图演示,在输入 Project name 的时候,Module nameModule file Location 自动进行改变,同时 Project locationModule file Location 完全一样,这也就表示,Project 目录和 Module 目录是同一个,所以此时 Project 目录下就会有 src 目录,但是我们应该明白其本质还是 Module 的目录。

关于 IntelliJ IDEA 的 Project 和 Module 终于解释清楚了,但是由于 IntelliJ IDEA 官网上又有一段话对此解释得不够好,特别是对 Eclipse 用户来讲:https://www.jetbrains.com/idea/help/eclipse-faq.html,其中有这样两句话:

An Eclipse workspace is similar to a project in IntelliJ IDEA

An Eclipse project maps to a module in IntelliJ IDEA

你可以把 IntelliJ IDEA 的 Project 当做 workspace 使用,IntelliJ IDEA 也是支持的,但是就像我们前面解释的那么那么多,这样是非常不符合其初衷的,所以请别把这段话当做教义去学习。对此 zeroturnaround 的大牛也有针对此进行了说明:http://zeroturnaround.com/rebellabs/getting-started-with-intellij-idea-as-an-eclipse-user/3/

IntelliJ IDEA 项目相关的几个重要概念介绍的更多相关文章

  1. 使用TortoiseSVN客户端管理IntelliJ IDEA项目的方法

    使用TortoiseSVN客户端管理IntelliJ IDEA项目的方法 今天在打开一个使用SVN管理的项目时,IntelliJ IDEA提示: Can't use Subversion comman ...

  2. 根据funID,personID获取最新规划包项目相关信息

    1.定义:根据funID,personID获取最新规划包项目相关信息(code projecttype(阶段) Pname(code+name) projectID) 项目表tbl_cfg_Proje ...

  3. IntelliJ 更改项目使用的 JDK 版本

    在当前使用的 IntelliJ 中的 JDK 版本为 1.8,如何修改 IntelliJ 使用的 JDK 版本为 1.11 呢? 你可以在 IntelliJ 中进行修改. 选择 File 后,然后选择 ...

  4. django_day10_项目相关

    django_day10_项目相关 展示数据的方法 数据对象obj 普通字段 obj.字段名 ====> 数据库该字段的值 带choices参数的 obj.字段名 ====> 数据库该字段 ...

  5. django_day11_项目相关

    django_day11_项目相关 新增和编辑 路由 url(r'^category_add/$', views.category_change, name='category_add'), url( ...

  6. django_day09_项目相关

    django_day09_项目相关 展示数据: 给模板一个querySet对象列表,循环出对象列表obj 普通字段 obj.字段名 ----> 数据库中的数据 外键 obj.外键 ------- ...

  7. django_day08_项目相关

    django_day08_项目相关 定义数据库表 from django.db import models # Create your models here. class User(models.M ...

  8. web页面相关的一些常见可用字符介绍

    首先是一张图片,是一张一些字符以及想对应的HTML实体表示的对照图片.如下: 一.引号模样或内心的些字符 请选择该表格要呈现的字体: 字符以及HTML实体 描述以及说明 " " 这 ...

  9. web页面相关的一些常见可用字符介绍——张鑫旭

    by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=1623 正文开始之前先 ...

随机推荐

  1. coursera python 学习总结

    为啥要写这篇总结?早上突然想到了四个字:知行合一.实践,总结,再实践,再总结经验,积累经验,为己所用.闲话少叙,来干货: 1.目标要单一,如果想要完成课程,还要健身,还要玩玩游戏.看看电影,还学别的课 ...

  2. <?php set_time_limit(10);

    <?php include('w_fun.php'); set_time_limit(10); Fatal error: Maximum execution time of 10 seconds ...

  3. php thread

    1-include('w_fun.php');页面已经在执行,则修改include中的函数,倒置旧页面不受影响:新页面生效:2-time  轮流 echo ' <script> windo ...

  4. java 重写 重载

    首先我们来讲讲:重载(Overloading) (1) 方法重载是让类以统一的方式处理不同类型数据的一种手段.多个同名函数同时存在,具有不同的参数个数/类型. 重载Overloading是一个类中多态 ...

  5. 【转】C# 解析JSON格式数据

    http://blog.csdn.net/coolszy/article/details/8606803 JSON简介 JSON(全称为JavaScript ObjectNotation) 是一种轻量 ...

  6. 【转】Xamarin.Android 入门之:Xamarin+vs2015 环境搭建

    Xamarin.Android 入门之:Xamarin+vs2015 环境搭建   一.前言 此篇博客主要写了如何使用搭建xamarin开发的环境,防止我自己万一哪天电脑重装系统了,可以直接看这篇博客 ...

  7. Tab指示符——Indicator

    先说说我们的思路吧. 其实思路也很简单,就是在咱们的导航下面画一个小矩形,不断的改变这个矩形距离左边的位置. 思路就这么简单,有了思路,接下来就是实现了,看代码: public class Indic ...

  8. 关于<a href='javascript:function()'>

    <a href='javascript:function()'> 这样写是为了让这个链接不要链接到新页面转而执行一段js代码.和onclick能起到同样的效果,一般来说,如果要调用脚本还是 ...

  9. ViewModel命令ICommand对象定义

    如果定义如下 public ICommand ViewMenuItemCommand: 那么UI绑定,则无法执行代理方法 需如下定义 public ICommand ViewMenuItemComma ...

  10. [LeetCode] Edit Distance(很好的DP)

    Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2 ...