Reasons why Maven project dependencies are not downloaded

Troubleshooting route Here I will focus on a solution I encountered on the Internet that has several other solutions

1. Maven warehouse configuration problem
   solution ideas: check the Maven warehouse source configuration, if not, delete all dependencies in the local warehouse and re-download


2. Idea uses Maven mismatch
   solution: Check whether the version of idea matches the version of Maven. For example, the maximum supported Maven version of idea in 2019 is 3.6.0.


3. SpringBoot multi-module projects use maven sub-projects without loading dependencies. The key point! ! !
     If you have tried the above two methods, then you have a high probability because of the error I encountered.
     At the beginning, introduce a pom management dependency label dependencyManagement

<dependencyManagement>
    <dependencies>
        <dependency>
                  XXX
        </dependency>
    </dependencies>
</dependencyManagement>

 DependencyManagement only declares dependencies, but does not implement imports, so sub-projects need to display the dependencies that need to be declared. If the dependency is not declared in the subproject, it will not be inherited from the parent project ; only if the dependency is written in the subproject and no specific version is specified, will the item be inherited from the parent project, and the version and scope Both are read from the parent pom; in addition, if a version number is specified in the subproject, the jar version specified in the subproject will be used.

Did you just reference the idea's maven Reimport in this code block to refresh dependencies without downloading dependencies from the warehouse?

The reference here will not actually load the dependency. The version of this dependency is actually declared here, and there is no actual reference to the dependency, so it will not be downloaded. Of course, it will not be loaded by manually importing the package.

It is correct that the pom declaration version of the dependent version should be managed first:

 

Then reference it in the sub-project Pom that actually needs to use this dependency, so that the sub-project will load the dependency

 Of course, this method can only solve the problem of not loading dependencies caused by the dependencyManagement tag

. Most of this error occurs because the direct clone open source project is not familiar with the system architecture dependency management and ignores the dependencyManagement tag.

I checked this error for two days, but I really didn’t notice this label at all. I tried changing the idea version to the maven version, and it made 
me cry stupidly.  

 

Guess you like

Origin blog.csdn.net/luxiangyan1923/article/details/125221594