'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);
}

兩者可以結合使用


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM