将dependencies放到dependencyManagement中,如下:
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.9</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- 那么,子模块在使用到junit的时候,只需要声明groupId和artifactId即可,即:
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>