Simply learn IDEA to integrate Maven

Create Maven project

Before creating a Maven project, you need to have your own local Maven warehouse. If not, please read this article to configure https://blog.csdn.net/ITMuscle/article/details/111932649

  • First create a new Maven project. Here you can choose to use the Maven template to create a Web project. Note that when selecting the template, you must select the webapp under maven.

    ps: Here we don't use Maven template to create, so we create the cleanest project without checking the option Create from archetype.

Insert picture description here

  • Click Next to jump to the following interface:

    Insert picture description here

  • Click Finish to successfully create the Maven project, as follows:

Insert picture description here

  • Create a directory, where the directory can not be created at will, said before the agreement is greater than the configuration .

    Create a Java directory and a resources directory under the main directory

    Create a Java directory under the test directory

    Insert picture description here

  • Set mark

    You can see that the color of each file directory above has changed, at this time we need to set it

    Right-click the directory> Mark Directory as> select the corresponding color to set, as shown in the figure above

    The blue java directory is used to store Java source code

    The resources directory is used to store resources

    The green java directory is used to store the test code

Insert picture description here

  • Create a web directory, because the Maven tool is used to develop web projects, so you need to create a web directory here

    File > Project Structure > Modules > + 选择 Web

Insert picture description here

  • Then select Artfacts> +

    Insert picture description here

  • Click Finish to complete the creation

Insert picture description here

At this point, a Web project with Maven is created.

Configure Maven repository

  • Open Settings> Build> Build Tools> Maven

    ps: If you are using the Maven template to create, the following configuration will be edited when creating.

Insert picture description here

  • Then select Importing under Maven to set the automatic import source code, you need to pay attention to the JDK version number to be consistent with your own.

Insert picture description here

At this point, Maven has been successfully integrated into IDEA.


Guess you like

Origin blog.csdn.net/ITMuscle/article/details/111938532