Detailing IntelliJ Idea creating a Maven project and setting up Java source directories

Source: Internet
Author: User

Warm tip : This tutorial GitHub address for "intellij-idea-tutorial", welcome to interested children's shoes star, Fork, error correction.

Maven is an excellent project management tool that gives us a complete lifecycle framework. Now, let's take a look at how to use IntelliJ idea to quickly create a Maven project.

As shown in the figure above, click Create New Project:

Callout 1: Maven option, callout 2: Project SDK, Project SDK, callout 3: Archetype,web project framework.

As shown in the figure above, click the Maven option, then select the SDK and select Maven-archetype-webapp from the frame to create the WEB project. Of course, we can also choose different frameworks for radically different needs so that idea automatically generates the project framework for us. Here, one thing we should pay special attention to is that theversion of Maven 3.3.1+ above requires a version of JDK 1.7+ to be used, otherwise there will be an exception so that MAVEN project creation fails. After the above operation is complete, click Next:

Callout 1: GroupId, Project coordinates, used with Artifactid, for marking items; Callout 2: Artifactid, Project coordinates, used with GroupId, marking items; Callout 3 : version, project versions, used with Artifactid, GroupID, for unique marking items.

As shown in the figure above, Artifactid, GroupID need to name ourselves, version defaults to 1.0-snapshot, which means that the project is an unstable snapshot version, by default. When the input is complete, click Next:

Callout 1: Maven home directory,maven main directory, the outermost directory, callout 2: User settings file,maven configuration file, callout 3: local repo Sitory,maven a local warehouse for storing dependency packs.

As shown in the figure above, after you configure it, click Next:

Callout 1: Project name, item title, Callout 2: Project location, item save location, callout 3: More settings, additional configuration, such as Configuration Project module location, The format of the project.

As shown in the figure above, we name the project name and module name Unified as Gitcode, and then, after configuration, click Next:

Callout 1:. Idea, automatically generated idea configuration file, callout 2: SRC, automatically generated Maven directory structure, callout 3: Build Sucess,maven Project to create a successful logo.

As shown in the figure above, when the console output build sucess, this means that Maven has been created. However, if we look closely at the MAVEN directory structure that the idea automatically generates for us, we find that this is not the same as the directory structure of the MAVEN project we recognize, it does not have a test directory with the main sibling, no resources directory, and no Java directory. Even the source directory is not marked out, why. In fact, Maven doesn't enforce that we have to create directories like test, resources, Java, and so it's just our custom and the convenience of managing projects that we build this directory structure. Next, we manually create a structure like test, resources, Java, and Mark Java as sources root, which is the source directory:

As shown in the figure above, take the MAC computer as an example, click the file, the PROJECT structure option in turn:

As shown above, select modules in the leftmost project structure list, click sources into our project structure view, then click on the SRC directory, right-click the menu bar, and click New Folder to create a new catalog:

As shown in the figure above, this is the newly created directory structure.

Now, select the Java directory and click Mark As:sources to mark the Java directory as the source directory:

As shown in the figure above, we have tagged the tests, resources, and test resources directories in the same way, where the WebApp directory is special, and we need to mark it as a resource directory for the project on the Web. Here, click on the + option above Gitcode:

Callout 1: +,add option, callout 2: Web, Project type.

Click the + option and the Web type, as shown in the above illustration:

Callout 1: Modify button, Callout 2: Shortcut Catalog option.

As shown in the figure above, Deploy descriptor need to point to the project's Web.xml file, in general, the default directory is inaccurate, we need to choose again.

Callout 1: Modify button, Callout 2: Shortcut Catalog option.

As shown in the figure above, the WEB resources directories need to point to the project's resource directory, the WebApp directory, which, like deploy descriptor, requires us to choose again.

As shown in the figure above, the Java source directory settings were successful when the Maven project was created.

———— ☆☆☆--return to the simplest IntelliJ idea Tutorial <-directory--☆☆☆ in the history of-> ————

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.