No MyBatis mapper was found in '[com.study.dal.***.mapper]' package
2017-10-25 00:58
507 查看
使用 MapperScannerConfigurer 自动扫描mapper下的文件时,一直出现下面警告: No MyBatis mapper was found in ‘[com.study.boot.dal.*.mapper]’ package.
并且也没有注册mapper的文件
配置如下
原因是: 由于增加了 annotationClass的配置, 导致只会扫描被 Resource 注解的文件,因此只需要把这段配置注释掉就ok
修改之后的配置如下
使用annotationClass的源码如下:
并且也没有注册mapper的文件
配置如下
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFaction" /> <property name="annotationClass" value="javax.annotation.Resource" /> <property name="basePackage" value="com.study.boot.dal.***.mapper" /> </bean>
原因是: 由于增加了 annotationClass的配置, 导致只会扫描被 Resource 注解的文件,因此只需要把这段配置注释掉就ok
修改之后的配置如下
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFaction" /> <property name="basePackage" value="com.study.boot.dal.***.mapper" /> </bean>
使用annotationClass的源码如下:
protected void registerDefaultFilters() { boolean acceptAllInterfaces = true; // if specified, use the given annotation and / or marker interface if (MapperScannerConfigurer.this.annotationClass != null) { addIncludeFilter(new AnnotationTypeFilter(MapperScannerConfigurer.this.annotationClass)); acceptAllInterfaces = false; } // override AssignableTypeFilter to ignore matches on the actual marker interface if (MapperScannerConfigurer.this.markerInterface != null) { addIncludeFilter(new AssignableTypeFilter(MapperScannerConfigurer.this.markerInterface) { @Override protected boolean matchClassName(String className) { return false; } }); acceptAllInterfaces = false; } if (acceptAllInterfaces) { // default include filter that accepts all classes addIncludeFilter(new TypeFilter() { public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { return true; } }); } }
相关文章推荐
- No MyBatis mapper was found in '' package. Please check your configura, Could not autowire field
- No MyBatis mapper was found in 'XXX' package. Please check your configuration
- [org.mybatis.spring.mapper.ClassPathMapperScanner]-No MyBatis mapper was found in '[com.xxx.xxx.dao]
- 解决main No MyBatis mapper was found in 的警告
- 解决main No MyBatis mapper was found in 的警告
- error: No resource identifier found for attribute 'showAsAction' in package 'com.ymeng.项目名字'
- No resource identifier found for attribute 'mode' in package 'com.aaa.bbb'
- `Error:(11) No resource identifier found for attribute 'srcCompat' in package 'com.codifythings.ligh
- No setter found for property 'mapperLocation' in class 'org.mybatis.spring.SqlSessionFactoryBean' [c
- error: No resource identifier found for attribute 'cardCornerRadius' in package 'com.example.test'
- 错误:No resource identifier found for attribute 'hover' in package 'com.indris.sample'
- 自定义View XML文件出现No resource identifier found for attribute 'xxx' in package 'xxx.xxx.xxx'错误
- No resource identifier found for attribute 'srcCompat' in package的解决办法
- 关于android自定义View时报error: No resource identifier found for attribute ‘XXX’ in package ‘
- Fiddler 手机端证书安装No root certificate was foundHave you enabled HTTPS traffic decryption in Fiddler yet
- No resource identifier found for attribute 'srcCompat' in package的解决办法
- 关于android自定义View时报error: No resource identifier found for attribute ‘XXX’ in package ‘
- No context type was found in the assembly
- Package libvirt was not found in the pkg-config search path
- error: No resource identifier found for attribute 'dropDownHorizontalOffset' in package 'android'