By Dulk www.cnblogs.com/deng-cc/p/6…

Intellij IDEA plugin is a must for Java programmers

The most important setting item in IDEA is this Project Structre, which is related to the operation of your Project.

Recently, the company happened to use IDEA rather than Eclipse, which I was familiar with before. In order to have a deeper understanding and use of the IDEA, I found various materials to study it again. Here is the output.

1.1 the Project

  • Project name:

Define the name of the project;

  • Project the SDK:

Set the JDK to use for this project. You can also add new JDK versions here.

  • The Project language level:

This is similar to the JDK, except that if you set JDK1.8 and only use 1.6 features, then you can set the language level to 1.6, which is the minimum requirement of the JDK for the compilation check of the project.

  • Project compiler output:

The default compile output directory in the project is shown in yellow. In fact, each module can set its own special output directory (Modules – (project) -paths-use module compile output path), so this setting is a bit weak.

1.2 Modules

1.2.1 Adding and deleting sub-items

A project can have multiple subprojects, each of which is equivalent to a module. Generally, our project is only a single one, and IntelliJ IDEA is also in the form of a single project by default, so only one module needs to be configured. (The two projects introduced here are for example only)

1.2.2 Sub-project Configuration

Each subproject corresponds to three configuration options: Sources, Paths, Dependencies:

  • Sources:

Display the directory resources of the project, which are required when the project is deployed, with different colors representing different types.

  • Paths:

You can specify the compile output directory for your Project, that is, the compile output address for your Project and test classes (instead of the default Project output address)

  • Dependencies:

Project dependencies

1.2.3 Adding and Deleting Frameworks (Web Deploy-1)

Under each subproject you can define the framework it uses, and here the Web part of the setup is highlighted.

1.3 Libraries

Jar packages can be displayed, jar packages can be added, and multiple Jars can be placed in a group, similar to jar package collation.

By default, each JAR package is a separate group (untested, to be determined).

1.4 called Facets

The official explanation:

When you select a framework (a facet) in the element selector pane, the settings for the framework are shown in the right-hand part of the dialog.

(When you click on a technical framework in the left pane, the Settings for that framework will be displayed on the right)

To be honest, I didn’t feel it working.

1.5 Artifacts (Web Deployment -2)

The package deployment Settings of the project, which is the more critical part of the project configuration, focus on it.

To understand what this means, let’s have a look at the official definition artifacts:

An artifact is an assembly of your project assets that you put together to test, deploy or distribute your software solution or its part. Examples are a collection of compiled Java classes or a Java application packaged in a Java archive, a Web application as a directory structure or a Web application archive, etc.

The integration of compiled Java classes, Web resources, etc., for testing, deployment, etc. More generally, this means how a module is packaged, such as War exploded, WAR, JAR, EAR, and so on. A Module with Artifacts can be deployed to the application server.

Jar: Java ARchive, usually used to aggregate a large number of Java class files, related metadata, and resource (text, image, etc.) files into a file for distribution of Java platform applications or libraries.

War: Web Application ARchive, a JAR file that contains JSPS, Java servlets, Java classes, XML files, tag libraries, static Web pages (HTML and related files) for distribution, and other resources that make up a Web application;

Exploded: You can use the word ‘exploded’ here to express that you are not constricted. This is the directory structure of the war, JAR, and other artifacts before compression. It is recommended to use this mode during development, so that the effect of modifying files is immediately apparent.

By default, the Modules and Artifacts output directories for the IDEA are already set and do not need to be changed; classes are automatically generated in the WEB-INF directory when the WAR package is typed, and the compiled files are then placed in it.

You may not understand the output directory here, didn’t you configure the output directory for file compilation? Why is there a directory that integrates these resources? What did it do? Intellij IDEA is one of the biggest problems in the process.

In fact, when you click run Tomcat, the default is to do the following:

  • Compile, IDEA does not compile after save/autosave, unlike Eclipse, which saves and compiles, so a compile is done before running the server. After compilation, the class file is stored in the specified project compilation output directory (see 1.2.2).

  • Create directory structures based on Settings in the artifact;

  • Copy all files from the root of the Web resource into the artifact’s directory (see 1.2.3);

  • Copy the classes directory in the build output directory to web-INF under the artifact (see 1.2.2);

  • Copy the required JAR package from the lib directory to WEB_INF under the artifact;

  • After the server runs successfully, the browser automatically opens to access the specified URL if necessary.

Note also here that the configured artifact needs to be added in Tomcat:

Refer to the link

www.jetbrains.com/help/idea/2… www.jetbrains.com/help/idea/2… www.cnblogs.com/52php/p/567… White-crucifix.iteye.com/blog/207083… My.oschina.net/lujianing/b…

Read more on my blog:

1.Java JVM, Collections, Multithreading, new features series tutorials

2.Spring MVC, Spring Boot, Spring Cloud series tutorials

3.Maven, Git, Eclipse, Intellij IDEA series tools tutorial

4.Java, backend, architecture, Alibaba and other big factory latest interview questions

Life is good. See you tomorrow