There are usually two reasons, configuration reason, or mapper relevant documents, mapper.java internal error or mapper.xml
If the configuration is the reason
1 solution
Unified configuration mapper
// Import org.mybatis.spring.annotation.MapperScan; Import org.springframework.boot.SpringApplication; Import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @MapperScan ( "com.example.mybatisplus.mapper") // put this together, do not write on the right path, if it is modular general path @MapperScan ( "com.kfit. *. mapper ")
public class Application { public static void main(String[] args){ System.out.println("hahahaha"); SpringApplication.run(Application.class, args); } }
Solution 2
Each mapper file configuration @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);
}
Both can be used in combination