zoukankan      html  css  js  c++  java
  • 'com.example.mybatisplus.mapper.PersonMapper' that could not be found.

    通常有两种原因,配置原因,或者是mapper相关文件,mapper.java或 mapper.xml内部错误

    如果是配置原因

    解决方式1

    统一配置mapper

    //import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    @MapperScan("com.example.mybatisplus.mapper")  //把这个加上,别写上正确的路径,如果是模块化一般路径为@MapperScan("com.kfit.*.mapper")  
    public class Application {
    
        public static void main(String[] args){
            System.out.println("hahahaha");
             SpringApplication.run(Application.class, args);
        }
    
        
    }

    解决方式2

    每个mapper文件配置@Mapper

    package com.example.mybatisplus.mapper;
    
    //import org.apache.ibatis.annotations.Mapper;
    
    import com.baomidou.mybatisplus.mapper.BaseMapper;
    import com.example.mybatisplus.entity.Person;
    @Mapper     //每个文件配置这个
    public interface PersonMapper extends BaseMapper<Person> {
    Integer listCount();
    Person findPersonById(Integer id);
    }

    两者可以结合使用

  • 相关阅读:
    Cocos2dx-背景无限循环播放
    centos 7端口和防火墙
    图片裁剪
    spring-boot图片压缩
    vue cli简介
    spring-boot的配置(实时生效)
    spring-boot打成war包放入tomcat运行
    spring-boot上传图片并访问
    linux链接ssh
    mysql远程访问
  • 原文地址:https://www.cnblogs.com/dianzan/p/11246034.html
Copyright © 2011-2022 走看看