错误: Error creating bean with name ‘abilityController‘

本文详细介绍了在SpringBoot项目中遇到的关于Mapper配置的问题及其解决方案,包括检查yml文件配置路径、确保项目包层级目录正确、使用@Mapper注解及确认XML映射文件路径等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

很多时候,我们在搭建SpringBoot项目时,也许会碰到这个问题,creating bean with name 这个问题一般都是路径问题,所以,解决办法很简单:

1.检查自己yml文件的配置路径

2.检查项目包层级目录对应

3.Mapper接口注解@Mapper

4.映射文件路径与返回值

报错一般如下:

 解决:

1.yml文件路径

server:
  port: 8484

spring:
    datasource:
      driver-class-name: com.mysql.cj.jdbc.Driver
      username: root
      password: 123456
      url: jdbc:mysql://localhost:3306/outdoors?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8

    redis:
      host: 127.0.0.1
      port: 6379


mybatis:
    mapper-locations: classpath:mapper/*.xml # mapper映射文件路径
    type-aliases-package: com.cn.wanxi.outdoorsback.domain #扫描Java实体类的,给类配置别名
    config-location: classpath:mybatis-config.xml #加载MyBatis的核心配置文件

2.层级目录于yml文件路径对应

3.注解@Mapper


@Mapper
public interface UserMapper {
    //根据用户名和密码查询用户对象
    UserModel finByUsernameAndPassword(UserModel userModel);
//查询所有用户信息
    List<UserModel> findAll(UserModel userModel);
//查询总条数
    int getCount(UserModel userModel);
//添加数据
    int add(UserModel userModel);
//修改
    int update(UserModel userModel);
//删除
    int delete(UserModel userModel);
//    修改状态
    int enable(UserModel userModel);
//查询id
    UserModel findById(UserModel userModel);
}

 4.xml文件路径

这些地方是比较注意的地方,确认无误就行了。

本人自己当时也是在yml文件里粗心了,故此分享一下,希望对大家有用! 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值