问题

Autowired mapper组件结果却爆红了
@mapper注解方式是通过在 xml中的namespace命名空间配置的

package com.example.demo123.mapper;

import com.example.demo123.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
public interface UserMapper {
    List<User> queryUserList();
    User queryById(int id);

    int deleteUser(int id);
    int addUser(User user);
}

但并不影响正常运行
可通过调整idea的警报级别解决
也可以使用另一种注解 :Repository,但是需要在配置文件中指明扫描xml的路径

mybatis:
  mapper-locations: classpath:mybatis/*Mapper.xml
  type-aliases-package: com.example.demo123.pojo
 posted on 2020-03-18 14:54  whiplasher  阅读(988)  评论(0编辑  收藏  举报