'com.example.mybatisplus.mapper.PersonMapper' that could not be found.

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

'com.example.mybatisplus.mapper.PersonMapper' that could not be found.

如果是配置原因

解决方式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);
}

两者可以结合使用

'com.example.mybatisplus.mapper.PersonMapper' that could not be found.

上一篇:Leetcode 283 移动零


下一篇:Python_code_七段数码管绘制实现_happy-new-year