Novice use mybatis3 of sadness, should also only novice to understand, online a bunch of solutions to solve the anomaly do not work, mentality is not good, hit the computer is possible, fortunately, my mentality can also, admit that their knowledge is not enough, only anger and learning, hehe, a little more.
Recently skilled SPRINGMVC+MYBATIS3 development framework, in the development environment encountered such as the title of the problem, code layered or ordinary controller, service, service Impl, mapper layer, Then use annotations to inject beans, annotated with JSR-330 specifications, similar to @inject, @Named.
Introduction cut here, read the newspaper wrong:
INFO: JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
Exception in thread "main" org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.join.stump.site.service.MenuService.queryMenuList
at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189)
at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43)
at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51)
at com.sun.proxy.$Proxy12.queryMenuList(Unknown Source)
at com.join.stump.site.service.impl.MenuServiceImpl.main(MenuServiceImpl.java:25)
Call Method:
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "stump-core-config.xml" });
MenuService menuService = (MenuService) context
.getBean("menuService");
System.err.println("menuService:"+menuService.queryMenuList(null));
}
Obviously, when calling the service method, there are two places that might make you wonder,
1, why reported invalid bound statement (not found): com.join.stump.site.service.MenuService.queryMenuList
2. Why the Service object type is Org.apache.ibatis.binding.MapperProxy
On the first question, the second question can be explained, because it is org.apache.ibatis.binding.MapperProxy This SQL is not available in the SQL mapping file using com.join.stump.site.service.MenuService.queryMenuList in MyBatis, so it is an error.
Then why there is a second problem, I also do not ride elder sister (intentional), after a party toss, see mybatis-spring official online paragraph, feel enlightened, try to adjust the next there is no problem. This question is very much related to my MyBatis configuration file. First look at the configuration before the error:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.join.stump" />
</bean>
Then look at the resolved configuration:
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.join.stump.site.mapper,com.join.stump.base.mapper" />
</bean>
Did you notice the difference? Then I give a description of the official website:
Mapperscannerconfigurer supports filtering by creating a mapper from the specified creation interface or annotations. The Annotationclass property specifies the name of the note to look for. The Markerinterface property specifies the parent interface to look for. If both are specified, the mapper added to the interface will match the two criteria.
by default, both properties are null, so all interfaces given in the base package can be loaded as mappers .
Well, you should be able to think of something, okay, I'll get it straight, Error in the configuration of Basepackage with Com.join.stump, so mapperscannerconfigurer do scan, the service also swept in, so, now can ride elder sister.
Besides Mybatis3:invalid bound statement (not found)