Intellij Idea中的库,项目,模块和包 [英] Libraries, projects, modules and packages in Intellij Idea
问题描述
我是初学程序员,我正在学习如何使用Intellij IDEA。 IntelliJ IDEA中的项目有一些不同的结构,如库,模块和包。
I'm a beginner programmer and I'm learning how to work with Intellij IDEA. A project in IntelliJ IDEA has some different structures like libraries, modules and packages.
有人可以解释这些结构与何时使用特定结构之间的区别吗?例如当它已经是模块的一部分时,我无法选择我的包名(类)。那些之间的联系是什么?我主要是难以理解包和模块之间的区别。
Can someone explain what the difference is between those structures and when to use a particular structure? e.g. I can't chose my package name (of a class) arbitrary when it's already part of a module. What is the connection between those? I'm primarily having difficulties understanding the difference between a package and a module.
推荐答案
intellij中的项目由模块组成。模块可以是java模块,也可以是android模块或其他。模块包含你的java代码和所有东西。模块可以引用可以是项目库或全局库的库。全局库只需定义一次。您需要的每个项目中的项目库。
A project in intellij consists of modules. Modules can be java modules, or android modules or whatever. Modules contain your java code and all that stuff. A Module can reference a library which can be a project library or a global library. Global libraries have to be defined only once. Project library in every project you need them.
包是一个java概念,与IDE无关。
Packages are a java concept and are IDE independent.
让我们说我想做一个小游戏。我会创建一个名为mySuperGame的intellij项目。然后我将从intellij创建两个java模块,称为逻辑和ui。在ui的模块设置中,我将指定一个项目库来使用opengl和dep。到逻辑。我的逻辑类的包名称是com.mysupergame.logic.XXX。
Lets say I wanna do a little game. I would create a intellij Project called "mySuperGame". Then I would create two java modules from intellij, called "logic" and "ui". In the module settings of "ui" I would specify a project library to use opengl and a dep. to "logic". The package name of my logic classes would be "com.mysupergame.logic.XXX".
参见 http://confluence.jetbrains.com/display/IDEADEV/Structure+of+IntelliJ+IDEA+Project 了解更多信息。
这篇关于Intellij Idea中的库,项目,模块和包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!