欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

No MyBatis mapper was found in xxx

程序员文章站 2022-07-14 11:33:50
...

SpringBoot 项目启动后输出了这样一个警告:

WARN 8904 --- [  restartedMain] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.xxx]' package. Please check your configuration.

很奇怪这个具体是在哪里配置的,难道有默认配置?

个人通过以下方式配置的也生效了,可为什么还会出现这样一个警告呢?

	@Bean
	public SqlSessionFactory sqlSessionFactoryBean() throws Exception {

		SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
		sqlSessionFactoryBean.setDataSource(dataSource());

		PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
		
		sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:com/xxx/xxx/mapping/*Mapper.xml"));
		sqlSessionFactoryBean.setTypeAliasesPackage("com.xxx.xxx.mapping");
		return sqlSessionFactoryBean.getObject();
	}

看到一段官方文档:

No MyBatis mapper was found in xxx

 @SpringBootApplication 是一个方便的复合注解,它包含:@Configuration @EnableAutoConfiguration @EnableWebMvc @ComponentScan  等注解。


相关标签: SpringBoot