Intellij 中project与module的区别

刚开始学习用intellij开发javaee,创建工程时有很多都是先创建工程而后添加module,一头雾水,之前用的eclipse。就在网上找了一些博客,这里总结一下,方便日后查找复习。

1.官方解释:

1.progect:

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. 
无论你在IDEA中做什么,都是处于一个project的上下文环境中。一个project是一个代表完整的软件解决方案的组织单元。它作为一个基础服务于编码助手,块重构,编码样式一致性等。 
你已经完成的产品可以被分解为一系列分离的、互相独立的module,但是project的定义把它们组合在一起并且联系成一个更大的整体。 

project本身不包含诸如源代码,构建脚本或者文档这些工件。它们是IDE的最高层组织,并且定义了工程宽度设置和IDEA所涉及到的模块与库的集合。

2.module:

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. 
module是你编译、运行、测试和独立调试的分离的功能单元。 

module包含它们被指定的任务所需要的一切:源代码,编译脚本,单元测试,部署描述和文档。然而,module只能在project的上下文中存在和起作用。

2.与其他软件类比

简言之:

IntelliJ系中的Project相当于Eclipse系中的workspace。

IntelliJ系中的Module相当于Eclipse系中的Project。

IntelliJ中一个Project可以包括多个ModuleEclipse中一个Workspace可以包括多个Project

应用:

在 IntelliJ IDEA 中Project是最顶级的结构单元,然后就是Module,一个Project可以有多个Module。目前,主流的大型项目结构基本都是多Module的结构,这类项目一般是按功能划分的,模块之间彼此可以相互依赖。通过这些Module的命名可以看出,它们都是处于同一个项目中的模块,彼此之间是有着不可分割的业务关系的。一个Project是由一个或多个Module组成,尽量让各模块处于同一项目之中,此时彼此之间具有互相依赖的关联关系。在这里,之所以说“尽量”,是因为 IntelliJ IDEA 的Project是一个没有具备任何编码设置、构建等开发功能的,主要起到一个项目定义、范围约束、规范类型的效果,或许,咱们也可以简单地理解Project就是一个单纯的目录,只是这个目录在命名上必须有其代表性的意义。在一般情况下,IntelliJ IDEA 是默认单ProjectModule的,这时ProjectModule合二为一,在没有修改存储路径的时候,显然ProjectModule具有强约束作用啦!不过说实话,这里就是将Module的内容放在了Project的目录下,实际上还是Module自己约束自己。

其他:

phpstorm中似乎在弱化Module的存在,把File菜单下的New Module菜单项目直接删除了。

在Android studio中仍存在。Android studio中,一个Project代表一个完整的APP,Module表示APP中的一些依赖库或独立开发的模块。比如可以新建一个library做为module,然后在主APP上点右键 open module setting的Dependencies中添加一个模块依赖。然后主APP中就可以使用module中的类了。


引用文章(表示感谢):https://www.aliyun.com/jiaocheng/305720.html

https://blog.csdn.net/qq_35246620/article/details/65448689

https://blog.csdn.net/zhangxiaoyang0/article/details/56843389(其中有一些操作过程)







猜你喜欢

转载自blog.csdn.net/weixin_40132006/article/details/80544467