springboot使用中mapper无效绑定

mybaits中的mapper无效绑定

  • 在配置中没有配置mapperloaction

  • mybatis:
      type-aliases-package: com.packet.pojo
      mapper-locations: classpath:mybatis/mapper/*.xml
    

Invalid bound statement (not found): com.packet.mapper.DeptMapper.queryAll

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Spring Boot使用Mapper需要进行以下步骤: 1. 在启动类上添加`@MapperScan`注解来扫描Mapper包,并将继承的Mapper接口添加到MyBatis配置。如下所示: ```java @SpringBootApplication @MapperScan("com.cloudsw.mapper") public class MapperApplication { public static void main(String[] args) { SpringApplication.run(MapperApplication.class, args); } } ``` 这样就可以将Mapper接口添加到MyBatis的配置。 2. 配置数据库和MyBatis。在`application.yml`配置文件添加数据库和MyBatis的配置。示例如下: ```yaml spring: datasource: name: clodsw-portal-dev url: jdbc:mysql://localhost:3306/cloudsw_portal?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&autoReconnect=true&allowPublicKeyRetrieval=true username: 123456 password: 123456 driver-class-name: com.mysql.cj.jdbc.Driver mybatis: mapper-locations: classpath:mapper/*.xml type-aliases-package: com.cloudsw.dto mapper: mappers: com.cloudsw.base.IBaseMapper identity: MYSQL ``` 在上述配置,配置了数据库连接信息和MyBatis的一些配置项。 3. 使用通用Mapper。通用Mapper是一个简化数据访问操作的工具,可以减少大量的重复代码。具体使用方法可以参考官方文档。 总结起来,在Spring Boot使用Mapper需要在启动类上添加`@MapperScan`注解,配置数据库和MyBatis的相关信息,以及按需使用通用Mapper来简化数据访问操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [一看就会一学就废之SpringBoot整合通用Mapper以及常用方法](https://blog.csdn.net/qq_45675378/article/details/115324620)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值