记 | 您所在的位置:网站首页 › java导入jar包另一个找不到 › 记 |
记-maven 多模块项目运行正常但是打包提示被依赖模块类找不到的问题
文章目录
记-maven 多模块项目运行正常但是打包提示被依赖模块类找不到的问题一、原因二、解决办法1.方法12.方法2
一、原因
父工程不正确地使用spring-boot-maven-plugin插件,导致“被依赖模块”例如(common模块),被打成可执行jar(flat jar);web模块无法从flat jar中按照约定的目录结构找到需要的类。 4.0.0 pom org.springframework.boot spring-boot-starter-parent 2.3.7.RELEASE true org.springframework.boot spring-boot-maven-plugin true repackage父工程和基础模块使用maven-compiler-plugin插件打包,web模块因为需要打成可执行jar,再使用spring-boot-maven-plugin打包。 父工程 4.0.0 pom org.springframework.boot spring-boot-starter-parent 2.3.7.RELEASE true org.apache.maven.plugins maven-compiler-plugin ${java.version} ${java.version} ${project.build.sourceEncoding} web模块(可执行jar) org.springframework.boot spring-boot-maven-plugin true repackage 2.方法2 4.0.0 pom org.springframework.boot spring-boot-starter-parent 2.3.7.RELEASE true org.springframework.boot spring-boot-maven-plugin exec true repackage参考: 官方文档 maven 多module环境下打包出现找不到包的解决方案 |
CopyRight 2018-2019 实验室设备网 版权所有 |