SpringBoot聚合父工程的子模块依赖问题解决过程

聚合模块规则

本文纯粹为了记载开发中的问题,所以可读性比较差,可能只有本人能看明白。


1. 创建父模块,在porm.xml中的下面内容

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.4.5</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

2. 创建子模块,子模块的父模块的porm.xml会体现父模块

3.创建子模块下的子模块

4.附加的全局模块common

说明:全局模块在maven中install的的时候,因为是全依赖状态,所以能很顺利的完成。

5.创建全局模块中的子模块

6.添加依赖

  • 1.在父模块中有子模块的体现
<modules>
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在基于Spring Boot框架的多模块聚合工程中,整合MyBatis需要进行以下几个步骤: 1. 首先,在聚合工程的pom.xml文件中添加MyBatis和MyBatis-Spring依赖,如下所示: ``` <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot-starter.version}</version> </dependency> ``` 2. 在每个模块的pom.xml文件中,添加对聚合工程模块依赖,以及对MyBatis和MyBatis-Spring依赖,如下所示: ``` <parent> <groupId>com.example</groupId> <artifactId>demo-parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <dependencies> <!-- 添加MyBatis和MyBatis-Spring依赖 --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis-spring-boot-starter.version}</version> </dependency> </dependencies> ``` 3. 配置MyBatis,可以在application.yml或者application.properties中添加如下配置: ``` mybatis: mapper-locations: classpath:mapper/*.xml configuration: map-underscore-to-camel-case: true ``` 其中,mapper-locations指定Mapper文件的位置,configuration中的map-underscore-to-camel-case指定将下划线命名转换为驼峰命名。 4. 编写Mapper接口和对应的Mapper.xml文件,在Mapper.xml文件中编写SQL语句。 5. 在Service层中注入Mapper接口,并在方法中调用Mapper接口中定义的方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个圆圈圈

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值