Today, when I configured the Sellercenter interface test environment, I found that some dependencies were not quite consistent:
For example, some dependent <scope> is written in a sub-project <dependencies> under the <dependency> tag,
And some of the dependent <scope> is written in <dependencyManagement> in the parent project.
I know the first kind of writing is right, then a way of writing but do not know right, from the online search, did not find a very precise answer, so he verified a.
The verification process to everyone, we can also practiced hand their own.
Three new items are created first, and the parent as a child project, ProjectA, PROJECTB.
In the parent project, a dependency is as follows:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
There is no dependency in subproject ProjectA, PROJECTB, Run command mvn Help:effective-pom under ProjectA, and you will find the dependency of JUnit 4.8.1 under a.
If I modify the dependencies in the parent project, this is as follows:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
Subproject ProjectA, PROJECTB below or no dependencies, Run command mvn help:effective-pom under ProjectA, you will find no dependency on JUnit 4.8.1 under a.
If I add a dependency of JUnit under ProjectA:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
After running the command mvn Help:effective-pom under ProjectA, you will find a dependency of JUnit 4.8.1 under a, and scope is test.
It is possible to verify that scope is written in the <dependencies> <dependency> in the subproject, or in the <dependencyManagement> in the parent project.
But one thing to note is that the difference between dependencies and dependencymanagement is:
The former, even if the dependency is not written in a subproject, the child project will still inherit the dependency from the parent project.
The latter, if the dependency is not written in a subproject, the dependency is not inherited from the parent project in the subproject, and the item is inherited from the parent project only if the dependency is written in the subproject, and both version and scope are read from the parent POM.
The difference between pluginmanagement and plugins with dependencymanagement and dependencies