Integrate with Springboot with the MyBatis official starter
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId> mybatis-spring-boot-starter</artifactid>
<version>1.1.1</version>
</dependency >
There is no problem starting the project in the IDE, but the following exception occurs when you hit the Jar startup project:
15:51:43.909 [main] DEBUG O.s.b.d.loggingfailureanalysisreporter-application failed to start due to an exception
org . Springframework.beans.factory.NoSuchBeanDefinitionException:No qualifying Bean found for dependency [ Org.zbt.service.jxc.dao.base.DataDicMapper]: Expected at least 1 bean which qualifies as Autowire candidate. Dependency annotations: {@org. springframework.beans.factory.annotation.Autowired (Required=true)} at
Org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound ( defaultlistablebeanfactory.java:1463)
...
.... Org.springframework.boot.starter.dubbo.startup.BootStrap.main (bootstrap.java:15)
2016-11-13 15:51:44.389 ERROR 3349---[
The exception can be known because mapper is not springboot scanned.
The configurable parameters provided by the official are only available in a few:
Config-location MyBatis XML config file (optional)
mapper-locations mapper xml config files (optional)
Type-aliases-package package to search for type aliases (optional)
Type-handlers-package package to search For type aliases (optional)
executor-type executor type:simple, Reuse, BATCH (optional)
configuration A MyBatis Configuration Bean
You can see that the location of the Mapper interface cannot be specified.
You can resolve this issue by adding the following configuration to the spring file that can be loaded into the springboot:
<bean class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" >
<property name= "Basepackage" value = "Org.zbt.service.jxc.dao.base"/>
<property name= "Annotationclass" value= " Org.apache.ibatis.annotations.Mapper "/>
</bean>