天天看點

No MyBatis mapper was found in xxx

版權聲明:本文為 testcs_dn(微wx笑) 原創文章,非商用自由轉載-保持署名-注明出處,謝謝。 https://blog.csdn.net/testcs_dn/article/details/80923260

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();
	}           

看到一段官方文檔:

@SpringBootApplication

 是一個友善的複合注解,它包含:

@Configuration

 @EnableAutoConfiguration 

@EnableWebMvc

 @ComponentScan  等注解。