How IDEA imports Maven projects, dependency management (using coordinates to import jar packages)

1. Copy the project to the workspace (that is, the folder where the project is located)
insert image description here
2. Find the pom file of the project, double-click to import it
insert image description here

Import jar package using coordinates

  1. <dependencies>Write tags in pom.xml
  2. <dependencies>Use <dependecy>import coordinates in labels
  3. groupId, artifactId, version that define the coordinates
  4. Click the refresh button to make the coordinates take effect

insert image description here
This is the refresh button

If you often forget to click refresh, then the configuration cannot be successful, but you can do
insert image description here
this without clicking refresh, and it will automatically refresh after the modification is completed

If you don’t know how to import the package, you can also Alt+Insert, click Dependency
insert image description here
and enter the name of the jar package you need to automatically generate the label

Dependency scope

  • By setting the dependent scope of the coordinates (scope), you can set the scope of the corresponding jar package: compilation environment, test environment, running environment
    insert image description here

compile : Acts on the compilation environment, test environment, and runtime environment.
test : Act on the test environment. The typical one is the Junit coordinates. When using Junit in the future, the scope will be specified as this value
provided: it acts on the compilation environment and the test environment. We will learn about servlet-api later. When using it, the scope must be set to this value, otherwise an error
will be reported during
runtime. The jdbc driver generally sets the scope to this value, and of course there is no problem if it is not set.

Guess you like

Origin blog.csdn.net/weixin_46362658/article/details/123900435