“Type interface is not known to the MapperRegistry” exception using mybatis

前端 未结 7 681
野性不改
野性不改 2021-02-02 15:23

I\'m setting up mybatis using annotations, and getting this helpful exception

org.apache.ibatis.binding.BindingException: Type interface org.foo.Bar is

7条回答
  •  一向
    一向 (楼主)
    2021-02-02 15:36

    add Mapper class to your SqlSessionFactory Configuration as this:

    SqlSessionFactory factory = new SqlSessionFactoryBuilder()
                .build(reader);
    
    //very import
    factory.getConfiguration().addMapper(BarMapper.class);
    
    SqlSession sqlSession = factory.openSession();
    

提交回复
热议问题