idea of artifacts, facets, modules What does it mean?

idea of ​​artifacts, facets, modules What does it mean?

Transfer: https://www.cnblogs.com/bityinjd/p/9284378.html

First, Modules, as shown below, Module generated in the beginning of jdwork, and did not put our new generation into the webapp and subdirectories inside, this way, then deploy and start the project at the time was not found web.xml this document. Corresponding to this is that the project directory structure webapp unmarked, with no distinction between the general folder.

I like this project, staffmanage, wherein the outermost layer is a staffManage ordinary folder, which has two modules, namely sm_service, sm_web, the former is not a web project, which is the web project

 

Then back to the first case, it is jdwork become a web project, we need to manually add, as follows:

Note to modify the two paths for the project in the true path, the default path may be wrong.

Look after the modified project directory, there is a change, as though I was not particularly aware of this dim.

 

Well, to solve this problem, the principles discussed some of the things.

Facets expressed a variety of frameworks, techniques and language used in the Module. These Facets let Intellij IDEA know how to treat module content, and to ensure consistent and appropriate framework and language.

Facets represents a module, some features, such as web, strtus2, spring, hibernate, etc.;
Artifacts is a concept of maven, showing how a module to be packaged, e.g. war exploded, war, jar, ear, etc. This packaging form ;

 

This involves a concept of IntelliJ Idea, Facet. If you observe, then, should be found, it Project in Project Structure section where, Modules, Libraries below that one, its role is to configure the framework to support the project.

 

比如我们现在要开发的是一个 web 项目,那就需要 web 相关的 Facet,事实上,如果没有这个配置支持,编译器也不知道这个项目是个 web 项目,也就不会去读取 web.xml 的配置,更无法被 tomcat 这种容器支持。

 

Facet 是和 Module 紧密结合的,你如果是在 Module 里配置了,那么 Facet 里边也会出现,而如果你先在 Facet 里配置,它会要求你选择 Module,所以结果是一致的。

 

再就是解释下 Artifacts,它的作用是整合编译后的 java 文件,资源文件等,有不同的整合方式,比如war、jar、war exploded 等,对于 Module 而言,有了 Artifact 就可以部署到 web 容器中了。其中 war 和 war exploded 区别就是后者不压缩,开发时选后者便于看到修改文件后的效果。

 

谈到 Artifacts,就得说一下几个输出目录的问题,Project 选项里有一个 Project compilerc output 目录,这个是整个 Project 的编译输出目录;Modules 的具体单个 Module 的 Path 选项里有个 Compiler output,可以选择继承 Project 或者自定义输出目录,如下图所示:

 

然后就是 Artifacts 也有一个 Output Directory,这几个的关系是怎样的呢?

前两者的关系好理解,就是一个总体和个体配置的关系。而 Artifacts 里的输出目录是跟容器有关系的,在容器运行的时候,会把前两者中起作用的那个(个体配置优先)的 classes 文件复制到 Artifacts 配置的目录的 WEB-INF下边,然后把 Module 的 Facet 里的资源文件目录复制到 Artifacts 目录里,再就是复制 lib 下的 jar 包到 WEB-INF 下,之后项目就可以启动了。

 

Guess you like

Origin blog.csdn.net/qq_28817739/article/details/93843599