主模块引入多个子模块,导致不同版本jar包冲突问题

请教贴!!!!!哪位大佬有解决方案,麻烦留言,谢谢!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
如果您的 Spring Boot 项目中包含多个模块一个公共模块,可以按照以下步骤进行打包: 1. 确保每个模块的 `pom.xml` 文件中都声明了对公共模块的依赖,例如: ```xml <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> </dependencies> ``` 2. 在公共模块的 `pom.xml` 文件中添加以下配置,使得公共模块可以被其他模块所依赖: ```xml <groupId>com.example</groupId> <artifactId>common</artifactId> <version>${project.version}</version> <packaging>jar</packaging> <dependencies> <!-- 公共模块的依赖 --> </dependencies> <build> <plugins> <!-- 公共模块的插件配置 --> </plugins> </build> ``` 3. 在每个模块的 `pom.xml` 文件中添加以下配置,指定需要打包的模块及其依赖: ```xml <parent> <groupId>com.example</groupId> <artifactId>parent</artifactId> <version>${project.version}</version> <relativePath>../pom.xml</relativePath> </parent> <artifactId>module1</artifactId> <packaging>jar</packaging> <dependencies> <dependency> <groupId>com.example</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> <!-- 模块的其他依赖 --> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- 模块的其他插件配置 --> </plugins> </build> ``` 4. 在父项目的 `pom.xml` 文件中添加以下配置,指定需要打包的模块及其依赖: ```xml <groupId>com.example</groupId> <artifactId>parent</artifactId> <version>${project.version}</version> <packaging>pom</packaging> <modules> <module>common</module> <module>module1</module> <module>module2</module> <!-- 其他模块 --> </modules> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <!-- 父项目的其他插件配置 --> </plugins> </build> ``` 5. 在父项目的根目录下执行 `mvn clean package` 命令,即可打包所有模块和公共模块。打包结果包含一个可执行的 Jar 文件和一个 lib 目录,其中 Jar 文件包含所有模块和公共模块的代码和依赖。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值