【maven】maven scope test

前言

记一次maven scope test的错误记录

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>${junit.version}</version>
    <scope>test</scope>
</dependency>

项目结构:
在这里插入图片描述
首先,test的依赖在1里面的dependencyManagement 管理的版本信息
然后我把一些常用的依赖都放到了common里面,然后其他项目信用common
最后,其他服务再引用common。

问题

这样引用原本是没问题的,其他依赖也都正常引用了。但是因为在 ①里面的test依赖的scope是test。相当于引用再引用。所以在③里面,就找不到了。 具体的官方解析没看,反正效果就是这样的。解决办法:把②里面的删掉,在③里面单独引用就成了

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
</dependency>

猜你喜欢

转载自blog.csdn.net/s1441101265/article/details/112257411