参考:https://blog.youkuaiyun.com/xjyr/article/details/79832408
概述:
maven 的<dependency>的scope属性可以为system,因为有些你依赖的jar包可能是没有maven坐标的,它完全不在maven体系中,这时候你可以把它下载到本地硬盘,然后通过system来引用
不过不推荐使用system,因为一个项目的pom.xml如果使用了scope为system的depend后,会导致传递依赖中断,即所有其他依赖本项目的项目都无法传递依赖了。
比如:假设A项目依赖了m.jar, n.jar, x.jar, 然后我们把A项目打包成了a.jar, 如果此时B项目依赖了A项目,则B项目通常自然就已经默认传递依赖了m.jar, n.jar, x.jar。
但是如果A项目的pom.xml文件出现了scope为system的depend,则B项目就只能依赖a.jar, 将无法传递依赖m.jar, n.jar, x.jar
解决方案:
1、使用maven私服,这样就不需要设置scope为system了
2、由于scope设置的system会导致第三方jar的依赖传递中断,这就会导致缺少第三方jar需要的一些依赖,这个就需要人工补齐缺少的dependency,或者第三方如果有源码,可以作为module引入项目,这样也可以解决
解决打包时scope为system的jar没有打进jar的问题:
主要起作用的是:
<configuration>
<!--将scope为system的依赖也打进jar包-->
<includeSystemScope>true</includeSystemScope>
</configuration>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--将scope为system的依赖也打进jar包-->
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
<!--如果不加package打包中没有mapper.xml文件-->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>