Creation of maven project under eclipse

1. Reason for selection

        Under normal circumstances, when we need a jar package, we need to download it ourselves, which will take time to find the appropriate jar; but using maven to create a project can reduce the occurrence of this situation and reduce the troubles of managing jar packages. There is a network. After configuring the dependencies, it will automatically download the jar package for you. It is very convenient and fast to use. The jar package under the same warehouse can be used between the parent class and the subclass project. You only need to configure the dependencies and reduce the need. The problem of introducing jar packages many times.

Second, maven configuration

1. Configure maven

        First open eclipse, click Window->Preferences (Figure 1) , enter the eclipse configuration page, find the Maven item, click Installations->Add to add the Maven installation directory, check it, and then click Apply to make it take effect (Figure 2).

figure 1:

figure 2:

2. The configuration file (settings.xml) for configuring the warehouse location

        Click the User Settings of the Maven item to add the directory of the configuration file (settings.xml), click Update Settings to update the configuration file, and then click Apply to make it effective (Figure 3)

image 3:

:

Configuration file (settings.xml):
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">
    <!-- Configure where the maven repository is located -->
    <localRepository>E:/Maven/.m2/repository</localRepository>
</settings>

3. Create a Maven project

In the blank space of the navigation bar on the left side of eclipse, click the right mouse button and select New->Project (as shown in Figure 4); or New->Other, search to find Maven Project. Or find the menu bar on the left and select Maven Project to create a new Maven project (as shown in Figure 5)

Figure 4:


Figure 5:


Then enter the creation of the Maven project (Figure 6). If you want to quickly create Maven, you can check Create a Simple Project, and click Next to enter Figure 7 to fill in the project information;

Image 6:

Figure 7:

If there is no selection, enter the template selection page (Figure 8), select it and click Next to enter the project filling interface (Figure 11)

Figure 8:

Figure 9:


There are two templates generally used, one is a quick build template (maven-archetype-quickstart), the other is a web project template (maven-archetype-webapp), the project structure they build is different, as shown below

Quick build template project structure:

web project template project structure:

Build the project according to your actual needs and choose the appropriate template


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324383940&siteId=291194637