解决
检查配置 启动类上加入
@MapperScan(basePackages = "com.xxx.mapper")
一个坑:使用mybatis-plus时不能使用自带的SqlSessionFactory,要使用MybatisSqlSessionFactory,在配置类中加入如下配置(springboot)
@Bean(name = "icspdbSessionFactory") // @Qualifier表示查找Spring容器中名字为test1DataSource的对象 public SqlSessionFactory test2SqlSessionFactory(@Qualifier("icspdbDataSource") DataSource datasource) throws Exception { // SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); // bean.setDataSource(datasource); // // org.apache.ibatis.session.Configuration configuration=new org.apache.ibatis.session.Configuration(); // configuration.setCallSettersOnNulls(true); // configuration.setLogImpl(org.apache.ibatis.logging.stdout.StdOutImpl.class); // bean.setConfiguration(configuration); MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean(); bean.setDataSource(datasource); MybatisConfiguration configuration=new MybatisConfiguration(); configuration.setCallSettersOnNulls(true); configuration.setLogImpl(org.apache.ibatis.logging.stdout.StdOutImpl.class); configuration.setMapUnderscoreToCamelCase(false); bean.setConfiguration(configuration); bean.setMapperLocations( // 设置mybatis的xml所在位置 new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml")); return bean.getObject(); }