How much do you know about the project structure used every day in idea?


One of the advantages of idea is that many configuration items can almost directly use the default items. However, targeted configuration is inevitably required for different projects. This paper will take you through the functions in project structure in detail and pay attention to collection in case of need.

First, let’s talk about the reason for writing this article. In the project, a group of springboot projects are opened in idea. The results of compilation and log output are inconsistent with expectations. Therefore, we have carefully studied the configuration items of project structure and found that there are many useful functions here, which are summarized and shared with you.

Project structure is “project structure”, which covers almost all personalized configuration items of a project, including the functions of modules, faces, libraries, artifacts, SDK and other modules.

Idea Project Structure

How to open the project structure

There are two ways to open project structure configuration. One way is to click the icon in ① above to directly open the relevant configuration interface.

Another way is to open it with shortcut keys. In Windows operating system, the default shortcut key is “Ctrl + Shift + Alt + s”; The default shortcut key for Mac operating system is “Command +;” combination.

The first way is to teach you a big trick when using idea: “help” search if you can’t find the corresponding configuration.

Idea Project Structure

Click the help menu and enter the project keyword to search. By default, all options related to the project keyword will be matched. When the mouse moves to the corresponding result, the menu position of the corresponding content will be automatically displayed on the left. Of course, you can also click to open it directly.

Not only can you do this here, but most operations can do so. Is it very cool to use!

Project configuration item

Generally, the first display selected by default after opening is project. Focus on items 1, 2, 3 and 4 in the figure below.

Idea Project Structure

The first item, project name, is the project name. For individuals, the project name here is generally consistent with the project directory name and the name in the POM file. Avoid inconsistencies and avoid that the idea displays multiple name IDs on the left.

If you open a group of projects, such as springboot projects, I will change the name here to a name like springboot all instead of one of them (the first one by default).

The second item is the project SDK. Configure the SDK usage of the project, which is often used. For example, if you open a new project, check whether the SDK version is consistent with the expected version. You can also edit the SDK in edit on the right.

Click Edit here to skip to SDKs in platform settings for operation. Take a look at the figure below. The operation is relatively simple and will not be expanded.

Idea Project Structure

The third item is project language level. Select the Java language level to support. If there are multiple modules (which can be understood as a group of projects), it will take effect for all modules.

Different JDK version choices have a certain impact on the syntax of the code. For example, if you choose a version before jdk8, an error will be reported if there is a lambda based syntax in the code. At present, jdk8 is the most used. Of course, if your project is old or new, you can also choose other versions.

The fourth item is project compiler output. Specify the path where IntelliJ idea will store the compiled results.

That’s the problem at the beginning. For a single project, you can configure an output path, or you can configure it independently in the module mentioned later.

However, for multiple module projects, there will be a common output directory. At this time, if the output log file path is in the form of “. / log”, the log may not be printed to the subproject, but output under the path specified here.

Modules configuration item

The configuration in modules is used more often, that is, when a group of items are used, the parameters of each item can be configured independently. Including project name, directory structure, output path, dependency, etc.

Idea Project Structure

Let’s analyze the four items marked in the figure below, of which the third and fourth items belong to the children of the source option.

First, the plus sign can import and add various module projects. Of course, the following minus sign can remove the corresponding projects.

Second, the project name and usage are consistent with the above, and it is also recommended to keep consistent in many places.

The third item, JDK version, is the same as in project, but this is for the current module.

Fourth, project directory structure. Classify the development directory of the module into folders, and specify the file types for different types of files. It is divided into sources, test, resources, test resources and excluded.

As the name suggests, sources puts the Java source code, test puts the test source code, resources puts the resource file, test resources puts the resource file used for the test, and excluded is the excluded item (such as the compiled tracet directory).

The most frequently used scenario here is the new folder. Right click a top-level directory to pop up “new folder” to create a directory, and then you can specify the type of the new folder. In common cases, such as the created project does not have test or test resources, you can add a directory here and specify the directory type.

At the same level as the sources option are paths and dependencies. Both operations are relatively simple. Paths is used to specify the compilation output path.
Idea Project Structure

Generally, the default value can be used. The inherit project compile output path inherits the project compile output path and uses the path specified for the project. That is, the out file path set in the project option.

Use module compile output path to compile the output path using the module; Output path is the compiled output path; Test output path compiles the output path for the test code.

The following Javadoc uses the available controls to combine a list of external JavaDocs storage locations associated with the module. If you don’t use it often, you won’t demonstrate it in detail.

The other is dependencies, which is mainly used to configure jar package dependencies.

Idea Project Structure

Here, you can also configure JDK, introduce other dependencies through the following plus sign, and configure the scope corresponding to the corresponding jar package.

The above explains several JDK configuration options. If there is a problem of JDK version modification or inconsistency in the actual combat process, it is recommended to check whether there is a problem with the JDK versions from beginning to end.

Libraries option configuration

In the libraries tab, you can define the module SDK and form a module dependency list.

Idea Project Structure

Through the operations in the plus sign, you can create a new item library, set classification, delete and other operations.

Facets option configuration

The faces option is mainly used to represent the features of modules, such as web, spring, hibernate, etc.

Idea Project Structure

Taking the spring boot project as an example, you can see the configuration file, startup class, MVC and other related features of the project. If it is a web project, you can also see the following information (the picture comes from the network).

Idea Project Structure

Artifacts option configuration

Artifact is a concept in Maven. This indicates the form of module packaging, such as war expanded, war, jar, etc;

Idea Project Structure

This form is rarely used when it is based on the springboot project, and it is more used when it is based on the web in the form of war package.

Among them, web projects have the expanded type, which can be understood as not archiving here, that is, directly deploy folders, JSP pages and classes into containers. It is recommended to use this mode during development to facilitate hot deployment.

By default, the output directories of modules and artifacts in idea are set and do not need to be changed. When typing war package, the classes directory will be automatically generated under the WEB-INF directory, and the compiled files will be put in it.

Other options

I won’t say much about other options, which are not commonly used. Among them, SDKs options are system development tools, global SDK configuration, and new JDK versions can be configured here. Global libraries is a global class library. You can configure some common class libraries. Problems when the project is abnormal, you can repair the project (fixed) according to the prompt.


Due to a problem in the actual combat process of the project, the research expands the knowledge system related to the whole project structure, which is also a mode of thinking and learning. Pay attention to the official account “new horizon of procedures”, and provide you with more similar experience and knowledge accumulation.

New horizon of program: wonderful and growth can’t be missed