情况:
将一个正常的叫做father项目拆分成三个部分
core
service
other
service 和other 都依赖core中的代码,core作为service和other 两个module抽象出来的公共部分。
service、core、other的pom配置文件中都存在parent指定
<parent>
<groupId>com.test</groupId>
<artifactId>father</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
service、other中引用core
<dependency>
<groupId>com.test</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
出现的问题是:
直接字core下面直接install时 所有core中引用的所有第三方jar包,都不能够加载在service package后的jar/war包下面,导致程序运行报错
原因:
因为core中有指定parent,导致core直接install是,pom文件找不到对应parent,所以该项目下pom引用的第三方包,不能正确的打包到service/other里面
解决方案:
在father目录下面运行 mvn install 命令,保证core的包能够正常加载到core压缩包下面,service/other 进行package时,能整成拿到引用包。
在将father项目拆分为core、service和other三个模块时,遇到service和其他模块无法正确加载core中引用的第三方jar包问题。原因是core模块的parent指定导致其在独立install时,依赖包未被正确打包。解决方案是在father目录下运行mvn install,确保所有依赖正确打包到各个模块中。
2755

被折叠的 条评论
为什么被折叠?



